![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Simple program to set a detect LED for an analog signal input larger than a threshold.
Diff: main.cpp
- Revision:
- 0:2d75e8930b10
--- /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); + } +}