Initial version. Illuminates the LED when the user button is held down. Otherwise, the LED is off. Variation on 21_Button_v5.
main.cpp@104:f2805e857b14, 2019-11-19 (annotated)
- Committer:
- arekzaluski
- Date:
- Tue Nov 19 14:11:50 2019 +0000
- Revision:
- 104:f2805e857b14
- Parent:
- 102:6979ad8bc0bc
- Child:
- 105:ed03c03b353e
Change timeout
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 82:abf1b1785bd7 | 1 | /* mbed Microcontroller Library |
mbed_official | 102:6979ad8bc0bc | 2 | * Copyright (c) 2019 ARM Limited |
mbed_official | 82:abf1b1785bd7 | 3 | * SPDX-License-Identifier: Apache-2.0 |
mbed_official | 82:abf1b1785bd7 | 4 | */ |
mbed_official | 82:abf1b1785bd7 | 5 | |
Jonathan Austin |
0:2757d7abb7d9 | 6 | #include "mbed.h" |
mbed_official | 100:ec006d6f3cb6 | 7 | #include "platform/mbed_thread.h" |
Jonathan Austin |
0:2757d7abb7d9 | 8 | |
Jonathan Austin |
0:2757d7abb7d9 | 9 | |
mbed_official | 102:6979ad8bc0bc | 10 | // Blinking rate in milliseconds |
arekzaluski | 104:f2805e857b14 | 11 | #define BLINKING_RATE_MS 1000 |
mbed_official | 88:bea4f2daa48c | 12 | |
mbed_official | 102:6979ad8bc0bc | 13 | |
mbed_official | 82:abf1b1785bd7 | 14 | int main() |
mbed_official | 82:abf1b1785bd7 | 15 | { |
mbed_official | 102:6979ad8bc0bc | 16 | // Initialise the digital pin LED1 as an output |
mbed_official | 102:6979ad8bc0bc | 17 | DigitalOut led(LED1); |
mbed_official | 82:abf1b1785bd7 | 18 | |
Jonathan Austin |
0:2757d7abb7d9 | 19 | while (true) { |
mbed_official | 102:6979ad8bc0bc | 20 | led = !led; |
mbed_official | 102:6979ad8bc0bc | 21 | thread_sleep_for(BLINKING_RATE_MS); |
Jonathan Austin |
0:2757d7abb7d9 | 22 | } |
Jonathan Austin |
0:2757d7abb7d9 | 23 | } |