Aan uit schakeling saxion opdracht 1.2
Dependencies: mbed
main.cpp@0:30ca94301688, 2018-03-10 (annotated)
- Committer:
- lennartgroen
- Date:
- Sat Mar 10 09:30:05 2018 +0000
- Revision:
- 0:30ca94301688
asd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lennartgroen | 0:30ca94301688 | 1 | /* |
lennartgroen | 0:30ca94301688 | 2 | Namen: Lennart Groen |
lennartgroen | 0:30ca94301688 | 3 | Klas: EMT1PSa |
lennartgroen | 0:30ca94301688 | 4 | Opdracht: Aan Uit schakeling |
lennartgroen | 0:30ca94301688 | 5 | Samengewerkt met: ... |
lennartgroen | 0:30ca94301688 | 6 | Datum: 10-03-2018 |
lennartgroen | 0:30ca94301688 | 7 | Inspiratie uit: |
lennartgroen | 0:30ca94301688 | 8 | |
lennartgroen | 0:30ca94301688 | 9 | */ |
lennartgroen | 0:30ca94301688 | 10 | |
lennartgroen | 0:30ca94301688 | 11 | #include <mbed.h> |
lennartgroen | 0:30ca94301688 | 12 | |
lennartgroen | 0:30ca94301688 | 13 | DigitalOut myled(LED1); |
lennartgroen | 0:30ca94301688 | 14 | DigitalIn myswitch(USER_BUTTON); |
lennartgroen | 0:30ca94301688 | 15 | |
lennartgroen | 0:30ca94301688 | 16 | |
lennartgroen | 0:30ca94301688 | 17 | int main() |
lennartgroen | 0:30ca94301688 | 18 | { |
lennartgroen | 0:30ca94301688 | 19 | |
lennartgroen | 0:30ca94301688 | 20 | int switchstate = 0; |
lennartgroen | 0:30ca94301688 | 21 | |
lennartgroen | 0:30ca94301688 | 22 | while(1){ |
lennartgroen | 0:30ca94301688 | 23 | if (myswitch == 0 && switchstate == 0){ |
lennartgroen | 0:30ca94301688 | 24 | myled = 1; |
lennartgroen | 0:30ca94301688 | 25 | wait(myswitch == 1); |
lennartgroen | 0:30ca94301688 | 26 | switchstate = 1; |
lennartgroen | 0:30ca94301688 | 27 | } |
lennartgroen | 0:30ca94301688 | 28 | else if (myswitch == 0 && switchstate == 1){ |
lennartgroen | 0:30ca94301688 | 29 | myled = 0; |
lennartgroen | 0:30ca94301688 | 30 | wait(myswitch == 1); |
lennartgroen | 0:30ca94301688 | 31 | switchstate = 0; |
lennartgroen | 0:30ca94301688 | 32 | } |
lennartgroen | 0:30ca94301688 | 33 | } |
lennartgroen | 0:30ca94301688 | 34 | |
lennartgroen | 0:30ca94301688 | 35 | } |