Ks0013 keyestudio Rotary Encoder Module: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
<br>
==Introduction==
==Introduction==
The rotary encoder can count the pulse outputting times during the process of its rotation in positive and reverse direction by rotating. This rotating counting is unlimited, not like potential counting. It can be restored to initial status to count from 0.
The rotary encoder can count the pulse outputting times during the process of rotation in positive and reverse direction by rotating. This rotating counting is unlimited, not like potential counting. It can be restored to initial state to count from 0.
<br>[[File:KS0013 (3).jpg|500px|frameless|thumb]]<br>
<br>[[File:KS0013 (3).jpg|500px|frameless|thumb]]<br>
<br>
<br>
==Specification==
==Specification==
Line 9: Line 12:


<br>
<br>
==Connection Diagram ==
==Connection Diagram ==
<br>[[File:Ks0013 旋转编码器.jpg|500px|frameless|thumb]]<br>
<br>[[File:Ks0013 旋转编码器.jpg|700px|frameless|thumb]]<br>


<br>
<br>
Line 79: Line 81:
<br>
<br>
==Result==
==Result==
Wiring well and uploading the above code, you can rotate the encoder module to randomly control two LED modules on and off.  
Wiring well and uploading the above code, you can rotate the encoder module to randomly control two LED modules on and off. <br>
<br>
When you rotate the encoder module, one LED module is turned on first but another one is off. If you continue to rotate the encoder module, one LED module becomes off while another one is turned on, repeatedly.
When you rotate the encoder module, one LED module is turned on first but another one is off. If you continue to rotate the encoder module, one LED module becomes off while another one is turned on, repeatedly.
<br>[[File:Ks0013.png|600px|frameless|thumb]]<br>
<br>[[File:Ks0013.png|600px|frameless|thumb]]<br>


<br>
<br>
==Resources ==
==Resources ==


'''Video'''<br>
'''Video'''<br>
http://www.keyestudio.com/wp/ks0013/
http://video.keyestudio.com/ks0013/


'''PDF and Code:'''<br>
'''PDF and Code:'''<br>
https://drive.google.com/open?id=1Haca67UfKEHv0ssZ5b8TKQKGxyi9z0e9
https://drive.google.com/open?id=1Haca67UfKEHv0ssZ5b8TKQKGxyi9z0e9


<br>
<br>
==Get One Now==
==Get One Now==
'''Official Website''' <br>
https://www.keyestudio.com/free-shipping-keyestudio-rotary-rotation-encoder-module-for-arduino-p0127.html


'''ebay''' <br>
*[https://www.keyestudio.com/free-shipping-keyestudio-rotary-rotation-encoder-module-for-arduino-p0127.html  '''Official Website''' ]
https://www.ebay.com/itm/Keyestudio-Rotary-Encoder-Sensor-Module-compatible-for-Arduino-UNO-R3-Mega2560-/132516046429






[[Category: Sensor]]
[[Category: Module]]

Revision as of 13:15, 12 April 2019


Introduction

The rotary encoder can count the pulse outputting times during the process of rotation in positive and reverse direction by rotating. This rotating counting is unlimited, not like potential counting. It can be restored to initial state to count from 0.
thumb


Specification

  • Power Supply: 5V
  • Interface: Digital



Connection Diagram


thumb


Sample Code

const int interruptA = 0;       
const int interruptB = 1;       
int CLK = 2;     // PIN2
int DAT = 3;     // PIN3
int BUTTON = 4;  // PIN4
int LED1 = 5;    // PIN5
int LED2 = 6;    // PIN6
int COUNT = 0;

void setup() 
 {
  attachInterrupt(interruptA, RoteStateChanged, FALLING);
 // attachInterrupt(interruptB, buttonState, FALLING);
  pinMode(CLK, INPUT); 
  digitalWrite(2, HIGH);  // Pull High Restance  
  pinMode(DAT, INPUT); 
  digitalWrite(3, HIGH);  // Pull High Restance 
 
pinMode(BUTTON, INPUT); 
  digitalWrite(4, HIGH);  // Pull High Restance
  pinMode(LED1, OUTPUT); 
  pinMode(LED2, OUTPUT); 
   Serial.begin(9600);
 }


void loop() 
{
  if  (!(digitalRead(BUTTON))) 
    {
     COUNT = 0;  
     Serial.println("STOP COUNT = 0");
     digitalWrite(LED1, LOW);
     digitalWrite(LED2, LOW);
     delay (2000);
    }
     Serial.println(COUNT);  
}

//-------------------------------------------
void RoteStateChanged() //When CLK  FALLING READ DAT
{
 if  (digitalRead(DAT)) // When DAT = HIGH IS FORWARD
   {
    COUNT++;
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    delay(20);
   }
 else                   // When DAT = LOW IS BackRote
   {
    COUNT--;
    digitalWrite(LED2, HIGH);
    digitalWrite(LED1, LOW);
    delay(20);
   }
}



Result

Wiring well and uploading the above code, you can rotate the encoder module to randomly control two LED modules on and off.
When you rotate the encoder module, one LED module is turned on first but another one is off. If you continue to rotate the encoder module, one LED module becomes off while another one is turned on, repeatedly.
thumb


Resources

Video
http://video.keyestudio.com/ks0013/

PDF and Code:
https://drive.google.com/open?id=1Haca67UfKEHv0ssZ5b8TKQKGxyi9z0e9



Get One Now