Dan Anderson
/
frdm_Distance1
Fork of frdm_Distance by
Diff: main.cpp
- Revision:
- 1:0b176971be25
- Parent:
- 0:cfc5bd6037db
- Child:
- 2:3e4aa1da40a5
--- a/main.cpp Sat Jun 27 21:30:54 2015 +0000 +++ b/main.cpp Sat Jun 27 21:45:09 2015 +0000 @@ -1,17 +1,23 @@ #include "mbed.h" +// Initializing all ins and outs: Program should get distance in cm when switch 2 is pressed and release and change LED from Green to red when Switch 2 is pressed DigitalOut led_red(LED_RED); +DigitalOut led_green(LED_GREEN); DigitalIn Ec(PTD5); DigitalOut Trig(PTD7); DigitalOut Pwr(PTD6); DigitalIn sw2(SW2); +Serial pc(USBTX, USBRX); -void sw2_release(void) +void check_sw2(void) { - led_red = !led_red; - printf("On-board button SW2 was released.\n"); + if (sw2 == 0) { + led_red = 0; + led_green = 1; + } } + int main() { sw2.rise(&sw2_release);