Simon Ford
/
ThresholdOutput
A simple example of controlling outputs based on input thresholds
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 AnalogIn input(p16); 00004 00005 DigitalOut pin_low(p24); 00006 DigitalOut pin_high(p25); 00007 DigitalOut led_low(LED4); 00008 DigitalOut led_high(LED3); 00009 00010 #define THRESHOLD_LOW (0.9 / 3.3) 00011 #define THRESHOLD_HIGH (3.0 / 3.3) 00012 00013 int main() { 00014 while(1) { 00015 pin_low = led_low = (input < THRESHOLD_LOW); 00016 pin_high = led_high = (input > THRESHOLD_HIGH); 00017 } 00018 }
Generated on Fri Jul 22 2022 09:56:19 by 1.7.2