Simple program to set a detect LED for an analog signal input larger than a threshold.
Revision 0:2d75e8930b10, committed 2010-08-15
- Comitter:
- philiptimson
- Date:
- Sun Aug 15 00:51:29 2010 +0000
- Commit message:
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Aug 15 00:51:29 2010 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+DigitalOut detect(LED1);
+DigitalOut peaked(LED2);
+AnalogIn signal(p20);
+#define threshold 0.5
+#define peak 0.99
+
+int main() {
+ while (1) {
+ printf("%f\n", signal.read());
+ if (signal.read() > threshold) detect=1; //turn on detect LED if the signal is greater than the threshold
+ else {detect=0;}
+ if (signal.read() > peak) peaked=1; // turn on peaked LED if the signal is too high
+ else peaked = 0;
+ wait(0.01);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Aug 15 00:51:29 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da