- [Show page]
- [Old revisions]
- [[unknown link type]]
- []
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
hardware:arduino [2015/03/04 17:54] admin [Rotary encoders] |
hardware:arduino [2015/03/04 18:07] (current) admin [Rotary encoders] |
||
---|---|---|---|
Line 62: | Line 62: | ||
<code> | <code> | ||
- | #define encoder0PinA 2 | + | #define encoderPinA 2 |
- | #define encoder0PinB 4 | + | #define encoderPinB 4 |
- | volatile unsigned int encoder0Pos = 0; | + | volatile int encoderPos = 0; |
void setup() { | void setup() { | ||
Line 72: | Line 72: | ||
MyInterrupt() { | MyInterrupt() { | ||
- | if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB)) { | + | if (digitalRead(encoderPinA) == digitalRead(encoderPinB)) { |
encoderPos++; | encoderPos++; | ||
} else { | } else { | ||
Line 80: | Line 80: | ||
</code> | </code> | ||
- | You can print the value outside the MyIntterupt() routine, which should be as fast&small as possible. | + | You can print the value **outside** not inside the MyIntterupt() routine, which should be as fast&small as possible. |
<code> | <code> | ||
void loop() { | void loop() { |
hardware/arduino.1425488045.txt.gz · Last modified: 2015/03/04 17:54 by admin