Demo program for using adafruit trellis.
Dependencies: Adafruit_Trellis mbed
Revision 0:1b1f6789bbdd, committed 2016-03-13
- Comitter:
- wliu88
- Date:
- Sun Mar 13 17:31:36 2016 +0000
- Commit message:
- hello world
Changed in this revision
diff -r 000000000000 -r 1b1f6789bbdd Adafruit_Trellis.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adafruit_Trellis.lib Sun Mar 13 17:31:36 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/wliu88/code/Adafruit_Trellis/#3a43c8b959d8
diff -r 000000000000 -r 1b1f6789bbdd main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Mar 13 17:31:36 2016 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" +#include "Adafruit_Trellis.h" + +I2C wire(p28, p27); + +int main() { + Adafruit_Trellis trellis = Adafruit_Trellis(); + trellis.begin(&wire, 0x70); + trellis.clear(); + int numKeys = 16; + for (uint8_t i=0; i<numKeys; i++) { + trellis.setLED(i); + trellis.writeDisplay(); + wait(0.05); + } + // then turn them off + for (uint8_t i=0; i<numKeys; i++) { + trellis.clrLED(i); + trellis.writeDisplay(); + wait(0.05); + } + + while(true) { + wait(0.03); + if (trellis.readSwitches()) { + // go through every button + for (uint8_t i=0; i<numKeys; i++) { + // if it was pressed... + if (trellis.justPressed(i)) { + // Alternate the LED + if (trellis.isLED(i)) + trellis.clrLED(i); + else + trellis.setLED(i); + } + } + // tell the trellis to set the LEDs we requested + trellis.writeDisplay(); + } + } +}
diff -r 000000000000 -r 1b1f6789bbdd mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Mar 13 17:31:36 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb \ No newline at end of file