Show DigitalIn class with BUTTON1 from mbed simulator
Dependents: Tinf_002_Bitmanipulation Labor_PTE
main.cpp@0:1b90d953ef92, 2019-11-13 (annotated)
- Committer:
- fpucher
- Date:
- Wed Nov 13 13:52:25 2019 +0000
- Revision:
- 0:1b90d953ef92
TINF, DigitalIn, BUTTON1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fpucher | 0:1b90d953ef92 | 1 | #define BUTTON1 p14 |
fpucher | 0:1b90d953ef92 | 2 | #include "mbed.h" |
fpucher | 0:1b90d953ef92 | 3 | // Flash an LED while a DigitalIn is true |
fpucher | 0:1b90d953ef92 | 4 | |
fpucher | 0:1b90d953ef92 | 5 | DigitalIn enable(BUTTON1); |
fpucher | 0:1b90d953ef92 | 6 | DigitalOut led(LED1); |
fpucher | 0:1b90d953ef92 | 7 | |
fpucher | 0:1b90d953ef92 | 8 | int main() { |
fpucher | 0:1b90d953ef92 | 9 | while(1) { |
fpucher | 0:1b90d953ef92 | 10 | if(enable) { |
fpucher | 0:1b90d953ef92 | 11 | led = !led; |
fpucher | 0:1b90d953ef92 | 12 | } |
fpucher | 0:1b90d953ef92 | 13 | wait(0.25); |
fpucher | 0:1b90d953ef92 | 14 | } |
fpucher | 0:1b90d953ef92 | 15 | } |