First version. Demo of PWM setup and speaker operation. Fine grain control of the PWM parameters is an advantage Mbed has over the Arduino environment.
main.cpp@105:ed03c03b353e, 2019-11-19 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Nov 19 15:00:03 2019 +0000
- Revision:
- 105:ed03c03b353e
- Parent:
- 104:f2805e857b14
- Child:
- 107:61b9c99a4e27
Corrected code snippet rendering on README. (#197)
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-blinky
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 |
mbed_official | 105:ed03c03b353e | 11 | #define BLINKING_RATE_MS 500 |
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 | } |