Demo program for using adafruit trellis.

Dependencies:   Adafruit_Trellis mbed

Files at this revision

API Documentation at this revision

Comitter:
wliu88
Date:
Sun Mar 13 17:31:36 2016 +0000
Commit message:
hello world

Changed in this revision

Adafruit_Trellis.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /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();
+        }    
+    }
+}
--- /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