MSOE EE2905 / Mbed 2 deprecated AnalogInterrupt

Dependencies:   mbed

Fork of AnalogInterrupt by Sheila Ross

Revision:
0:db459a4b2e6b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 12 21:40:42 2017 +0000
@@ -0,0 +1,75 @@
+/*
+AnalogInterrupt
+
+ 
+ The circuit:
+ * Three analog comparators
+ * photoresistor from comparator + inputs to +3.3V
+ * 10K resistor from comparator + inputs to ground
+ * Four resistors (1K or more) in series from ground to +3.3V
+ * Junction of each resistor to a single comparator - input
+ * Outputs of comparators to digital pins D2, D3, D4
+ 
+ created 1 Jul 2009
+ modified 9 Apr 2012
+ by Tom Igoe 
+ 
+ modified for Nucleo / mbed 12 Aug 2017
+ by Sheila Ross
+ 
+ This example code is in the public domain.
+ 
+ */
+
+
+#include "mbed.h"
+
+
+// Define the interrupt pins
+InterruptIn dark_dim(D2);
+InterruptIn dim_medium(D3);
+InterruptIn medium_bright(D4);
+
+// Create a serial connection over our USB
+Serial pc(USBTX, USBRX);
+
+void dark();
+void dim();
+void medium();
+void bright();
+
+int main() {
+  
+    pc.baud(9600);  // Set serial communication speed
+    dark_dim.fall(&dark);
+    dark_dim.rise(&dim);
+    dim_medium.fall(&dim);
+    dim_medium.rise(&medium);
+    medium_bright.fall(&medium);
+    medium_bright.rise(&bright);
+
+    while(1) {
+        wait(1); 
+
+    }
+}
+
+void dark() {
+    pc.printf("dark\n");
+}
+
+void dim() {
+    pc.printf("dim\n");
+}
+
+void medium() {
+    pc.printf("medium\n");
+}
+
+void bright() {
+    pc.printf("bright\n");
+}
+
+
+
+