Electronic Components Datasheet Search
  English  ▼

X  

KY-040 Datasheet(PDF) 4 Page - JOY-IT

Part # KY-040
Description  KY-040 Rotary encoder
PDF  6 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Manufacturer  JOY-IT [JOY-IT]
Direct Link  https://joy-it.net/
Logo JOY-IT - JOY-IT

KY-040 Datasheet(HTML) 4 Page - JOY-IT

  KY-040 Datasheet HTML 1Page - JOY-IT KY-040 Datasheet HTML 2Page - JOY-IT KY-040 Datasheet HTML 3Page - JOY-IT KY-040 Datasheet HTML 4Page - JOY-IT KY-040 Datasheet HTML 5Page - JOY-IT KY-040 Datasheet HTML 6Page - JOY-IT  
Zoom Inzoom in Zoom Outzoom out
 4 / 6 page
background image
KY-040 Rotary encoder
Serial.println ("Rotation detected: ");
Serial.print ("Rotational direction: ");
if (Richtung)
{
Serial.println ("Clockwise");
}
else
{
Serial.println("Counterclockwise");
}
Serial.print("Current position: ");
Serial.println(Counter);
Serial.println("------------------------------");
}
// Preparation for the next run:
// The current value will be the last value for the next run.
Pin_clk_Letzter = Pin_clk_Aktuell;
// Reset funciton to save the current position
if (!digitalRead(button_pin) && Counter!=0)
{
Counter = 0;
Serial.println("Position resetted");
}
}
Connections Arduino:
CLK
= [Pin 3]
DT
= [Pin 4]
Button
= [Pin 5]
+
= [Pin 5V]
GND
= [Pin GND]
Code example download
KY-40_rotary-encoder_ARD
Code example Raspberry Pi
The program checks which pin has changed first, to get the rotational direction, after detecting a change at
the pin status. You will get the rotational direction after you compare the current status of the pins with the
last status. After detecting the rotational direction, the steps from the start will be counted and outputted.
Pushing the button of the rotary encoder will reset the current position.
# coding=utf-8
# Needed modules will be imported and configured
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
# Declaration and initialisation of the input pins which are connected with the sensor.
PIN_CLK = 16
PIN_DT = 15
Export: 16.06.2017
Copyright by Joy-IT - Published under CC BY-NC-SA 3.0
Page 193 of 214



Html Pages

1 2 3 4 5 6


Datasheet Download

Go To PDF Page


Link URL



Does ALLDATASHEET help your business so far?  [ DONATE ] 

About Alldatasheet   |   Advertisement   |   Contact us   |   Privacy Policy   |   Link to Datasheet    |   Link Exchange   |   Manufacturer List
All Rights Reserved©Alldatasheet.com


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
Russian : Alldatasheetru.com  |   Korean : Alldatasheet.co.kr  |   Spanish : Alldatasheet.es  |   French : Alldatasheet.fr  |   Italian : Alldatasheetit.com
Portuguese : Alldatasheetpt.com  |   Polish : Alldatasheet.pl  |   Vietnamese : Alldatasheet.vn
Indian : Alldatasheet.in  |   Mexican : Alldatasheet.com.mx  |   British : Alldatasheet.co.uk  |   New Zealand : Alldatasheet.co.nz
Family Site : ic2ic.com  |   icmetro.com