controlling(Turning on and off) led through ext switch through interrupts - buggy
Dependencies: mbed
main.cpp@0:d839aded6393, 2016-11-14 (annotated)
- Committer:
- sivaieee
- Date:
- Mon Nov 14 21:03:07 2016 +0000
- Revision:
- 0:d839aded6393
EXT SWITCH WITH INTERRUPTS A LIL BUGGY
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sivaieee | 0:d839aded6393 | 1 | #include "mbed.h" |
sivaieee | 0:d839aded6393 | 2 | |
sivaieee | 0:d839aded6393 | 3 | DigitalOut myled(LED1); |
sivaieee | 0:d839aded6393 | 4 | DigitalOut vrefh(D8); |
sivaieee | 0:d839aded6393 | 5 | DigitalIn mySw(D11); |
sivaieee | 0:d839aded6393 | 6 | Serial pc(USBTX, USBRX); |
sivaieee | 0:d839aded6393 | 7 | InterruptIn event(D11); |
sivaieee | 0:d839aded6393 | 8 | |
sivaieee | 0:d839aded6393 | 9 | void trigger_rise(){ |
sivaieee | 0:d839aded6393 | 10 | pc.printf("rise\n"); |
sivaieee | 0:d839aded6393 | 11 | myled = 0; |
sivaieee | 0:d839aded6393 | 12 | } |
sivaieee | 0:d839aded6393 | 13 | void trigger_fall(){ |
sivaieee | 0:d839aded6393 | 14 | pc.printf("fall\n"); |
sivaieee | 0:d839aded6393 | 15 | myled=1; |
sivaieee | 0:d839aded6393 | 16 | } |
sivaieee | 0:d839aded6393 | 17 | |
sivaieee | 0:d839aded6393 | 18 | int main() { |
sivaieee | 0:d839aded6393 | 19 | vrefh = 0; |
sivaieee | 0:d839aded6393 | 20 | event.rise(&trigger_rise); |
sivaieee | 0:d839aded6393 | 21 | event.fall(&trigger_fall); |
sivaieee | 0:d839aded6393 | 22 | while(1){ |
sivaieee | 0:d839aded6393 | 23 | //pc.printf("waiting\n"); |
sivaieee | 0:d839aded6393 | 24 | |
sivaieee | 0:d839aded6393 | 25 | } |
sivaieee | 0:d839aded6393 | 26 | } |