photocell to led matrix touch display

Dependencies:   mbed Adafruit_LEDBackpack USBDevice

Files at this revision

API Documentation at this revision

Comitter:
chessemaster5000
Date:
Wed Dec 05 22:18:09 2018 +0000
Commit message:
Never Eat Pears

Changed in this revision

Adafruit_LEDBackpack.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.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
diff -r 000000000000 -r c88ac8c87673 Adafruit_LEDBackpack.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Adafruit_LEDBackpack.lib	Wed Dec 05 22:18:09 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/luizhespanha/code/Adafruit_LEDBackpack/#f066d5347c60
diff -r 000000000000 -r c88ac8c87673 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Wed Dec 05 22:18:09 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#53949e6131f6
diff -r 000000000000 -r c88ac8c87673 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 05 22:18:09 2018 +0000
@@ -0,0 +1,77 @@
+#include "mbed.h"
+#include "Adafruit_LEDBackpack.h"
+#include "Adafruit_GFX.h"
+ 
+I2C i2c(p9, p10); //declare led matrix 12c ports
+ 
+Adafruit_8x8matrix matrix = Adafruit_8x8matrix(&i2c); //set up matrix
+//AnalogIn sensor0(p16);
+//AnalogIn sensor1(p17);
+//AnalogIn sensor2(p18);    // declare photocells and their pins
+//AnalogIn sensor3(p19);
+//AnalogIn sensor4(p20);
+//DigitalOut pin8 (p8);  //power
+
+AnalogIn cell0(p15);
+AnalogIn cell1(p16);
+AnalogIn cell2(p17);
+AnalogIn cell3(p18);
+AnalogIn cell4(p19);
+AnalogIn cell5(p20);
+DigitalOut pin8(p8);
+
+float threshold = 0.2;  //Whatever makes a good sensitivity level
+
+int leds[8][8];
+int row;
+int col;
+
+int main() {
+    matrix.begin(0x70);
+   pin8=1; //power on
+      
+while(1) {
+      for (row = 7; row >=1; row--)
+         for (col = 0; col <=7; col++)
+            leds[row][col] = leds[row+1][col];  // These nested loops move everything down one row, except the top row
+
+      leds[0][0] = (int)(cell0 + threshold);   // These assignments fill the top row with the cell values
+      leds[0][1] = (int)(cell1 + threshold);   // Each value should be 0 or 1
+      leds[0][2] = (int)(cell2 + threshold);
+      leds[0][3] = (int)(cell3 + threshold);
+      leds[0][4] = (int)(cell4 + threshold);
+      leds[0][5] = (int)(cell5 + threshold);
+      
+      printf("Value0 = %f\r\n", cell0.read());
+      printf("Value1 = %f\r\n", cell1.read()); 
+      printf("Value2 = %f\r\n", cell2.read()); 
+      printf("Value3 = %f\r\n", cell3.read()); 
+      printf("Value4 = %f\r\n", cell4.read());  
+      wait(1.0); 
+      
+        matrix.clear();
+                   
+        if(cell0 <= 0.2){
+        matrix.drawPixel (0, 0, LED_ON);}
+        else  matrix.drawPixel (0, 0, LED_OFF);
+             
+        if(cell1 <= 0.2){
+        matrix.drawPixel (1, 0, LED_ON);}
+        else  matrix.drawPixel (1, 0, LED_OFF);     
+        
+        if(cell2 <= 0.2){
+        matrix.drawPixel (2, 0, LED_ON);}
+        else  matrix.drawPixel (2, 0, LED_OFF);
+        
+        if(cell3 <= 0.2){
+        matrix.drawPixel (3, 0, LED_ON);}
+        else  matrix.drawPixel (3, 0, LED_OFF);
+           
+        if(cell4 <= 0.2){
+        matrix.drawPixel (4, 0, LED_ON);}
+        else  matrix.drawPixel (4, 0, LED_OFF);
+
+  matrix.writeDisplay();  // write the changes we just made to the display
+  wait(0.2);
+  }
+}
diff -r 000000000000 -r c88ac8c87673 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 05 22:18:09 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file