| Electronic Components Datasheet Search |
|
KY-034 Datasheet(PDF) 49 Page - AG Electronica |
|
|
|||||||||||||||||||||||||||||
KY-034 Datasheet(HTML) 49 Page - AG Electronica |
|
49 / 50 page ![]() void loop () { count++; if (digitalRead (buttonPin)) { setLights (HIGH, HIGH, HIGH); } else { int change = getEncoderTurn (); int newPeriod = longPeriod + (change * 1000); if (newPeriod >= 1000 && newPeriod <= 10000) { longPeriod = newPeriod; } if (count> targetCount) { setState (); count = 0; } } delay (1); } int getEncoderTurn () { // Return -1, 0, or +1 static int oldA = LOW; static int oldB = LOW; int result = 0; int newA = digitalRead (aPin); int newB = digitalRead (bPin); if (newA != oldA || newB != oldB) { //Something has changed if (oldA == LOW && newA == HIGH) { result = - (oldB * 2 - 1); } } oldA = newA; oldB = newB; return result; } int setState () { if (state == 0) { setLights (HIGH, LOW, LOW); targetCount = longPeriod; state = 1; } |
|
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 |
| 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 |