Buzzer example for mbed apps board or shield

Dependencies:   C027 mbed

Fork of IoTWorkshopLCD by MBED_DEMOS

Committer:
sam_grove
Date:
Mon Feb 03 18:17:54 2014 +0000
Revision:
3:abcecbc8c198
Parent:
2:0e7e13c81df4
forgot LCD for apps board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:4ea8268e9d66 1 #include "mbed.h"
sam_grove 0:4ea8268e9d66 2 #include "C027.h"
sam_grove 0:4ea8268e9d66 3 #include "C12832_lcd.h"
sam_grove 0:4ea8268e9d66 4
sam_grove 2:0e7e13c81df4 5 #define MBED_APPS_SHIELD
sam_grove 2:0e7e13c81df4 6 //#define MBED_APPS_BOARD
sam_grove 1:ac55ff7b1a7d 7
sam_grove 0:4ea8268e9d66 8 #if defined(MBED_APPS_SHIELD)
sam_grove 1:ac55ff7b1a7d 9 PwmOut spkr(D6);
sam_grove 2:0e7e13c81df4 10 DigitalOut myled(P3_25);
sam_grove 2:0e7e13c81df4 11 C12832_LCD lcd(D11, D13, D12, D7, D10);
sam_grove 0:4ea8268e9d66 12 #elif defined(MBED_APPS_BOARD)
sam_grove 1:ac55ff7b1a7d 13 PwmOut spkr(p26);
sam_grove 3:abcecbc8c198 14 C12832_LCD lcd(p5, p7, p6, p8, p11);
sam_grove 2:0e7e13c81df4 15 DigitalOut myled(LED1);
sam_grove 0:4ea8268e9d66 16 #else
sam_grove 0:4ea8268e9d66 17 #error application board not defined
sam_grove 0:4ea8268e9d66 18 #endif
sam_grove 0:4ea8268e9d66 19
sam_grove 1:ac55ff7b1a7d 20 int main()
sam_grove 1:ac55ff7b1a7d 21 {
sam_grove 2:0e7e13c81df4 22 lcd.cls();
sam_grove 2:0e7e13c81df4 23 lcd.locate(0.,3);
sam_grove 2:0e7e13c81df4 24 lcd.printf("Buzzer test!\n");
sam_grove 0:4ea8268e9d66 25 while(1) {
sam_grove 1:ac55ff7b1a7d 26 for(int j=0; j<3; j++) {
sam_grove 1:ac55ff7b1a7d 27 for (float i=2000.0; i<4000.0; i+=100) {
sam_grove 1:ac55ff7b1a7d 28 spkr.period(1.0/i);
sam_grove 1:ac55ff7b1a7d 29 spkr=0.5;
sam_grove 1:ac55ff7b1a7d 30 wait(0.1);
sam_grove 1:ac55ff7b1a7d 31 myled = !myled;
sam_grove 1:ac55ff7b1a7d 32 }
sam_grove 1:ac55ff7b1a7d 33 spkr=0.0;
sam_grove 1:ac55ff7b1a7d 34 wait(2.0f);
sam_grove 1:ac55ff7b1a7d 35 }
sam_grove 0:4ea8268e9d66 36 }
sam_grove 0:4ea8268e9d66 37 }