Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of frdm_Grove_Buzzer_Example by
main.cpp@0:53c936ea1ae7, 2016-01-02 (annotated)
- Committer:
- GregC
- Date:
- Sat Jan 02 01:19:38 2016 +0000
- Revision:
- 0:53c936ea1ae7
Freedom Seeed Grove Buzzer Example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GregC | 0:53c936ea1ae7 | 1 | #include "mbed.h" |
GregC | 0:53c936ea1ae7 | 2 | |
GregC | 0:53c936ea1ae7 | 3 | DigitalOut buzzer(D2); |
GregC | 0:53c936ea1ae7 | 4 | DigitalOut led_green(LED_GREEN); |
GregC | 0:53c936ea1ae7 | 5 | InterruptIn sw2(SW2); |
GregC | 0:53c936ea1ae7 | 6 | |
GregC | 0:53c936ea1ae7 | 7 | void sw2_release(void) |
GregC | 0:53c936ea1ae7 | 8 | { |
GregC | 0:53c936ea1ae7 | 9 | led_green = !led_green; |
GregC | 0:53c936ea1ae7 | 10 | buzzer = !buzzer; |
GregC | 0:53c936ea1ae7 | 11 | |
GregC | 0:53c936ea1ae7 | 12 | printf("On-board button SW2 was released.\n"); |
GregC | 0:53c936ea1ae7 | 13 | } |
GregC | 0:53c936ea1ae7 | 14 | |
GregC | 0:53c936ea1ae7 | 15 | int main() |
GregC | 0:53c936ea1ae7 | 16 | { |
GregC | 0:53c936ea1ae7 | 17 | sw2.rise(&sw2_release); |
GregC | 0:53c936ea1ae7 | 18 | while (true) { |
GregC | 0:53c936ea1ae7 | 19 | } |
GregC | 0:53c936ea1ae7 | 20 | } |
GregC | 0:53c936ea1ae7 | 21 | |
GregC | 0:53c936ea1ae7 | 22 | |
GregC | 0:53c936ea1ae7 | 23 | |
GregC | 0:53c936ea1ae7 | 24 | |
GregC | 0:53c936ea1ae7 | 25 | |
GregC | 0:53c936ea1ae7 | 26 |