This example positions a lit LED in the I2C LED array using the rotary encoder

Dependencies:   mbed

main.cpp

Committer:
chris
Date:
2010-03-02
Revision:
0:498b9b4a7bb9

File content as of revision 0:498b9b4a7bb9:

#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);
              
    }
}