Buzzer example for mbed apps board or shield
Fork of IoTWorkshopLCD by
Diff: main.cpp
- Revision:
- 1:ac55ff7b1a7d
- Parent:
- 0:4ea8268e9d66
- Child:
- 2:0e7e13c81df4
--- a/main.cpp Mon Feb 03 04:54:17 2014 +0000 +++ b/main.cpp Mon Feb 03 05:00:28 2014 +0000 @@ -6,21 +6,27 @@ #define MBED_APPS_BOARD DigitalOut myled(LED1); + #if defined(MBED_APPS_SHIELD) - C12832_LCD lcd(D11, D13, D12, D7, D10); + PwmOut spkr(D6); #elif defined(MBED_APPS_BOARD) - C12832_LCD lcd(p5, p7, p6, p8, p11); + PwmOut spkr(p26); #else #error application board not defined #endif -int main() { +int main() +{ while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); - lcd.locate(0,0); - lcd.printf("Hello IoT Workshop\n"); + for(int j=0; j<3; j++) { + for (float i=2000.0; i<4000.0; i+=100) { + spkr.period(1.0/i); + spkr=0.5; + wait(0.1); + myled = !myled; + } + spkr=0.0; + wait(2.0f); + } } }