A simple example of controlling outputs based on input thresholds

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
simon
Date:
Sat Nov 03 09:47:23 2012 +0000
Commit message:
First implementation

Changed in this revision

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 b3a636717bab main.cpp
--- /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
diff -r 000000000000 -r b3a636717bab mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Nov 03 09:47:23 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06
\ No newline at end of file