Luca Mottola
/
IOTAtelier1819-DISCO-ButtonBusy
Example using the user button on DISCO L475E IOT01, using busy waits
main.cpp@0:e7c102a4c673, 2018-11-08 (annotated)
- Committer:
- lmottola
- Date:
- Thu Nov 08 16:59:47 2018 +0000
- Revision:
- 0:e7c102a4c673
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lmottola | 0:e7c102a4c673 | 1 | #include "mbed.h" |
lmottola | 0:e7c102a4c673 | 2 | |
lmottola | 0:e7c102a4c673 | 3 | DigitalIn button(USER_BUTTON); // Change to match your board |
lmottola | 0:e7c102a4c673 | 4 | DigitalOut led(LED1); |
lmottola | 0:e7c102a4c673 | 5 | |
lmottola | 0:e7c102a4c673 | 6 | #define BUTTON_PRESS 0 |
lmottola | 0:e7c102a4c673 | 7 | |
lmottola | 0:e7c102a4c673 | 8 | int main() { |
lmottola | 0:e7c102a4c673 | 9 | while(1) { |
lmottola | 0:e7c102a4c673 | 10 | if(BUTTON_PRESS == button){ |
lmottola | 0:e7c102a4c673 | 11 | led = !led; |
lmottola | 0:e7c102a4c673 | 12 | wait(1); |
lmottola | 0:e7c102a4c673 | 13 | } |
lmottola | 0:e7c102a4c673 | 14 | } |
lmottola | 0:e7c102a4c673 | 15 | } |