Chris Styles / Mbed 2 deprecated EA_RotaryEncoder

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "RotaryEncode.h"
00003 #include "PCA9532.h"
00004 
00005 RotaryEncode RE(p16,p17);
00006 PCA9532 leds (p28,p27,0xc0);
00007 
00008 int main() {
00009 
00010     int position = 0;
00011 
00012     while(1) {
00013  
00014        int offset = RE.read();
00015        
00016        if ((offset > 0) && (position < 15)) {
00017            position++;
00018        }
00019        else if ((offset < 0) && (position > 0)) {
00020            position--;
00021        }
00022        
00023        leds.write(0x1 << position);       
00024        wait (0.2);
00025               
00026     }
00027 }
00028 
00029