Philip Timson
/
Analog_Threshold_Detector
Simple program to set a detect LED for an analog signal input larger than a threshold.
main.cpp
- Committer:
- philiptimson
- Date:
- 2010-08-15
- Revision:
- 0:2d75e8930b10
File content as of revision 0:2d75e8930b10:
#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); } }