KY-040 Rotary encoder module

KY-040 Rotary encoder module
KY-040 Rotary encoder moduleKY-040 Rotary encoder moduleKY-040 Rotary encoder moduleKY-040 Rotary encoder moduleKY-040 Rotary encoder module
หมวดหมู่ Sensor/Encoder
ราคาปกติ 120.00 บาท
ลดเหลือ 80.00 บาท
สถานะสินค้า พร้อมส่ง
สภาพ สินค้าใหม่
ลงสินค้า 13 ต.ค. 2557
อัพเดทล่าสุด 20 ก.ค. 2560
จำนวน
ชิ้น
หยิบลงตะกร้า
บัตรประชาชน
บุ๊คแบ๊งค์
คุ้มครองโดย LnwPay

Rotary encoder 20 Pulse. With the buttons on the rotary encoder.

Link >>> http://forum.arduino.cc/index.php?topic=242356.0

Link >>> http://bigdanzblog.wordpress.com/2014/08/16/using-a-ky040-rotary-encoder-with-arduino/

Example Code.

volatile boolean TurnDetected;

volatile boolean up;

 

const int PinCLK=2;                   // Used for generating interrupts using CLK signal

const int PinDT=3;                    // Used for reading DT signal

const int PinSW=4;                    // Used for the push button switch

 

void isr ()  {                    // Interrupt service routine is executed when a HIGH to LOW transition is detected on CLK

 if (digitalRead(PinCLK))

   up = digitalRead(PinDT);

 else

   up = !digitalRead(PinDT);

 TurnDetected = true;

}

 

void setup ()  {

 pinMode(PinCLK,INPUT);

 pinMode(PinDT,INPUT);  

 pinMode(PinSW,INPUT);

 digitalWrite(PinCLK, HIGH);

 digitalWrite(PinDT, HIGH);

 digitalWrite(PinSW, HIGH);

 attachInterrupt (0,isr,FALLING);   // interrupt 0 is always connected to pin 2 on Arduino UNO

 Serial.begin (9600);

 Serial.println("Start");

}

 

void loop ()  {

 static long virtualPosition=0;    // without STATIC it does not count correctly!!!

 

 if (!(digitalRead(PinSW))) {      // check if pushbutton is pressed

   virtualPosition=0;              // if YES, then reset counter to ZERO

   Serial.print ("Reset = ");      // Using the word RESET instead of COUNT here to find out a buggy encoder

   

   Serial.println (virtualPosition);

 }  

 

 if (TurnDetected)  {    // do this only if rotation was detected

   if (up)

     virtualPosition++;

   else

     virtualPosition--;

   TurnDetected = false;          // do NOT repeat IF loop until new rotation detected

   Serial.print ("Count = ");  

   Serial.println (virtualPosition);

 }

}

วิธีการชำระเงิน

สอบถามสินค้าหรือต้องการใบเสนอราคาหรือใบกำกับภาษีโปรดติดต่อทางร้านก่อนสั่งซื้อครับผม

- ติดต่อผ่าน LINE ID : csanthanaboun
- เบอร์โทร 0909761799

บมจ. ธนาคารกสิกรไทย สาขาวังบูรพา ออมทรัพย์
พร้อมเพย์ สาขา- mobile
ธนาคารไทยพาณิชย์ จำกัด (มหาชน) สาขาศรีนครพิงค์ ออมทรัพย์
Scan this!
นาย ชาติไทย สันธนะบูรณ์
090-xxxxxx-9
Accept All Banks | รับเงินได้จากทุกธนาคาร

ติดตามพัสดุ

*ใส่ เบอร์มือถือ หรือ email ที่ใช้ในการสั่งซื้อ

ติดต่อเรา

0909761799

ระบบสมาชิก

สถิติร้านค้า

หน้าที่เข้าชม332,811 ครั้ง
ผู้ชมทั้งหมด120,848 ครั้ง
พูดคุย-สอบถาม