Freedom Seeed Grove Buzzer Example
Dependencies: mbed
Fork of frdm_Grove_Buzzer_Example by
Simply Import this Program into your mbed compiler
Select Compile to generate the binary file
Plug the Grove Shield v2 on the top of your FRDM-K64F
Connect on end of the 4-pin Grove cable to the Buzzer module and the other end to the port D2 of the Grove Adapter.
Drag n drop the frdm_Grove_Buzzer_Example_K64F.bin into the mbed drive from your file explorer
Wait for download to complete
Press the Reset/SW1 button of your FRDM-K64F board to launch the program
The RGB LED should now power on Green
Press the SW2 user push-button of the FRDM-K64F and you should hear the buzzer ringing while RGB LED will power off.
To stop the buzzer, just release the SW2 button and press it again
Happy Buzzer'ing :D
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 |
