A simple example of controlling outputs based on input thresholds

Dependencies:   mbed

Revision:
0:b3a636717bab
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 03 09:47:23 2012 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+ 
+AnalogIn input(p16);
+
+DigitalOut pin_low(p24);
+DigitalOut pin_high(p25);
+DigitalOut led_low(LED4);
+DigitalOut led_high(LED3);
+ 
+#define THRESHOLD_LOW (0.9 / 3.3)
+#define THRESHOLD_HIGH (3.0 / 3.3)
+
+int main() {
+    while(1) {
+        pin_low = led_low = (input < THRESHOLD_LOW);
+        pin_high = led_high = (input > THRESHOLD_HIGH);
+    }
+}
\ No newline at end of file