Seeed Grove Buzzer example. The buzzer buzzes on for .5 second and then off for .5 second.

Dependencies:   mbed

Fork of Seeed_Grove_Buzzer by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Sep 04 02:41:17 2014 +0000
Revision:
0:3da67ed4c5a4
Buzzer works. PWM Period = 1s, duty cycle = .5s

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 0:3da67ed4c5a4 1 #include "mbed.h"
mbedAustin 0:3da67ed4c5a4 2
mbedAustin 0:3da67ed4c5a4 3 DigitalOut buzzer(D8);
mbedAustin 0:3da67ed4c5a4 4
mbedAustin 0:3da67ed4c5a4 5 int main() {
mbedAustin 0:3da67ed4c5a4 6 int on = 1, off = 0;
mbedAustin 0:3da67ed4c5a4 7
mbedAustin 0:3da67ed4c5a4 8 while(1){
mbedAustin 0:3da67ed4c5a4 9 buzzer = on;
mbedAustin 0:3da67ed4c5a4 10 wait(.5);
mbedAustin 0:3da67ed4c5a4 11 buzzer = off;
mbedAustin 0:3da67ed4c5a4 12 wait(.5);
mbedAustin 0:3da67ed4c5a4 13 }
mbedAustin 0:3da67ed4c5a4 14 }