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.
main.cpp
00001 /*Program Example 4.7: Plays the tune "Oranges and Lemons" on a piezo buzzer, using PWM 00002 */ 00003 #include "mbed.h" 00004 PwmOut buzzer(p21); 00005 00006 //frequency array 00007 float frequency[]= {659,554,659,554,440,494,554,587,494,659,554,440}; 00008 float beat[]= {1,1,1,1,1,0.5,0.5,1,1,1,1,2}; //beat array 00009 int main() 00010 { 00011 while (1) { 00012 for (int i=0; i<=11; i++) { 00013 buzzer.period(1/(2*frequency[i])); // set PWM period 00014 buzzer=0.5; // set duty cycle 00015 wait(0.4*beat[i]); // hold for beat period 00016 } 00017 } 00018 } 00019
Generated on Sat Jul 30 2022 03:34:16 by
1.7.2