Chris Styles
/
EA_RotaryEncoder
This example positions a lit LED in the I2C LED array using the rotary encoder
Diff: main.cpp
- Revision:
- 0:498b9b4a7bb9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 02 08:27:23 2010 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "RotaryEncode.h" +#include "PCA9532.h" + +RotaryEncode RE(p16,p17); +PCA9532 leds (p28,p27,0xc0); + +int main() { + + int position = 0; + + while(1) { + + int offset = RE.read(); + + if ((offset > 0) && (position < 15)) { + position++; + } + else if ((offset < 0) && (position > 0)) { + position--; + } + + leds.write(0x1 << position); + wait (0.2); + + } +} + +