Maciej Zemlo
/
PRS_R1_AssTest
netemera prs
Diff: main.cpp
- Revision:
- 0:9dffac13db39
- Child:
- 1:db05ea2d0fe7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 26 08:18:20 2019 +0000 @@ -0,0 +1,59 @@ +#include "mbed.h" + +Serial serial ( PA_9 , PA_3 ); + +DigitalOut led_blue ( PA_5 ); +DigitalOut led_red ( PA_8 ); +DigitalOut led_orange ( PA_10 ); + +InterruptIn int_pa_0 ( PA_0 ); +DigitalIn pulse ( PA_2 ); +DigitalIn pulse_safe ( PB_5 ); +DigitalIn flow_dir ( PB_9 ); +DigitalIn case_open ( PA_3 ); + +DigitalIn sw1 ( PB_2 ); +DigitalIn sw2 ( PB_6 ); +DigitalIn sw3 ( PB_7 ); +DigitalIn sel ( PA_3 ); + + +// Toggle LED +void toggle_led () +{ + wait (0.1); //stan musi być utrzymany przez min. 0.1s + if ( pulse == 1 ) + led_blue = !led_blue; + if ( pulse_safe == 1 ) + led_red = !led_red; + if ( flow_dir == 1 ) + led_orange = !led_orange; +} + +int main() { + + led_blue = 1; + led_red = 1; + led_orange = 1; + + // Change LEDs blinking frequency when button is pressed + int_pa_0.fall( &toggle_led ); + + while ( 1 ) + { + wait ( 0.5 ); + serial.printf ( "DIP switch status:\n\r" ); + if ( sw1 ) + serial.printf ( "SW1 = 1\n\r" ); + else + serial.printf ( "SW1 = 0\n\r" ); + if ( sw2 ) + serial.printf ( "SW2 = 1\n\r" ); + else + serial.printf ( "SW2 = 0\n\r" ); + if ( sw3 ) + serial.printf ( "SW3 = 1\n\r" ); + else + serial.printf ( "SW3 = 0\n\r" ); + } +}