Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- xiaohonglv
- Date:
- 2016-06-09
- Revision:
- 0:72ee6ba483f8
- Child:
- 1:f6f3187e44c5
File content as of revision 0:72ee6ba483f8:
#include "mbed.h"
PwmOut buzzer(p23);
// red light
while (flag = 1);
{
int main() {
speaker.period_ms(1); //1ms period 1k Hz //
speaker = 0.5; //50% duty cycle //
}
}
// yellow light
while (flag = 2);
{
float frequency[]= {659,554,659,554,550,494,554,587,494,659,554,440}; //music frequency array
float beat[]= {1,1,1,1,1,0.5,0.5,1,1,1,1,2}; //beat array
int
main()
{
while (1) {
for (
int
i=0;
i<=11;
i++) {buzzer.period(1/(frequency[i])); // PMW period 1/frequency
buzzer=0.5; //50% duty cycle
wait(0.5*beat[i]); //hold for beat period
}
}
}
}
//green light
while (flag = 3);
{
int main() {
speaker.period_ms(1); //1ms period 1k Hz //
speaker = 0; //0% duty cycle //
}