
First commit. Hello World program for non_blocking_Led_Buzzer library
Dependencies: non_blocking_Led_Buzzer
main.cpp@0:01eddb20f50f, 2016-11-21 (annotated)
- Committer:
- tsungta
- Date:
- Mon Nov 21 06:43:50 2016 +0000
- Revision:
- 0:01eddb20f50f
Hello World program for non_blocking_Led_Buzzer library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tsungta | 0:01eddb20f50f | 1 | #include "mbed.h" |
tsungta | 0:01eddb20f50f | 2 | #include "Buzzer.h" |
tsungta | 0:01eddb20f50f | 3 | #include "Led.h" |
tsungta | 0:01eddb20f50f | 4 | |
tsungta | 0:01eddb20f50f | 5 | Buzzer buzzer(A1); |
tsungta | 0:01eddb20f50f | 6 | DigitalOut led1(LED2); |
tsungta | 0:01eddb20f50f | 7 | Led led(LED3); |
tsungta | 0:01eddb20f50f | 8 | |
tsungta | 0:01eddb20f50f | 9 | #define tone_num 5 |
tsungta | 0:01eddb20f50f | 10 | #define schedule_num 7 |
tsungta | 0:01eddb20f50f | 11 | float tone[tone_num] = {262, 294, 330, 349, 392}; |
tsungta | 0:01eddb20f50f | 12 | uint8_t toggle[schedule_num] = {1,1,1,0,1,0,1}; |
tsungta | 0:01eddb20f50f | 13 | |
tsungta | 0:01eddb20f50f | 14 | |
tsungta | 0:01eddb20f50f | 15 | |
tsungta | 0:01eddb20f50f | 16 | // main() runs in its own thread in the OS |
tsungta | 0:01eddb20f50f | 17 | // (note the calls to Thread::wait below for delays) |
tsungta | 0:01eddb20f50f | 18 | int main() { |
tsungta | 0:01eddb20f50f | 19 | |
tsungta | 0:01eddb20f50f | 20 | buzzer.playMelody(tone, tone_num, 0.5); |
tsungta | 0:01eddb20f50f | 21 | led.toggleLed(toggle, schedule_num, 0.5); |
tsungta | 0:01eddb20f50f | 22 | |
tsungta | 0:01eddb20f50f | 23 | while (true) { |
tsungta | 0:01eddb20f50f | 24 | led1 = !led1; |
tsungta | 0:01eddb20f50f | 25 | wait(2); |
tsungta | 0:01eddb20f50f | 26 | led.simpleBlink(1); |
tsungta | 0:01eddb20f50f | 27 | printf("hello\r\n"); |
tsungta | 0:01eddb20f50f | 28 | } |
tsungta | 0:01eddb20f50f | 29 | } |
tsungta | 0:01eddb20f50f | 30 |