A simple example of controlling outputs based on input thresholds

Dependencies:   mbed

main.cpp

Committer:
simon
Date:
2012-11-03
Revision:
0:b3a636717bab

File content as of revision 0:b3a636717bab:

#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);
    }
}