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 #include "mbed.h" 00002 #include "beep.h" 00003 Beep buzzer(p23); 00004 00005 DigitalOut myled(LED1); 00006 00007 void play(char* note); 00008 00009 void popcorn() { 00010 00011 play("e"); 00012 play("d"); 00013 play("e"); 00014 play("c"); 00015 play("gb"); 00016 play("c"); 00017 play("eb"); 00018 play("w"); 00019 play("e"); 00020 play("d"); 00021 play("e"); 00022 play("c"); 00023 play("gb"); 00024 play("c"); 00025 play("eb"); 00026 play("w"); 00027 00028 play("e"); 00029 play("f#"); 00030 play("g"); 00031 play("f#"); 00032 play("g"); 00033 play("e"); 00034 play("f#"); 00035 play("e"); 00036 play("f#"); 00037 play("d"); 00038 play("e"); 00039 play("d"); 00040 play("e"); 00041 play("d"); 00042 play("e"); 00043 00044 play("w"); 00045 00046 play("e"); 00047 play("d"); 00048 play("e"); 00049 play("c"); 00050 play("gb"); 00051 play("c"); 00052 play("eb"); 00053 play("w"); 00054 play("e"); 00055 play("d"); 00056 play("e"); 00057 play("c"); 00058 play("gb"); 00059 play("c"); 00060 play("eb"); 00061 play("w"); 00062 00063 play("e"); 00064 play("f#"); 00065 play("g"); 00066 play("f#"); 00067 play("g"); 00068 play("e"); 00069 play("f#"); 00070 play("e"); 00071 play("f#"); 00072 play("d"); 00073 play("e"); 00074 play("d"); 00075 play("e"); 00076 play("d"); 00077 play("g"); 00078 00079 } 00080 00081 00082 void play(char* note) { 00083 if (note=="a") { 00084 buzzer.beep(880,0.1); 00085 } 00086 if (note=="b") { 00087 buzzer.beep(987,0.1); 00088 } 00089 if (note=="c") { 00090 buzzer.beep(1024,0.1); 00091 } 00092 if (note=="d") { 00093 buzzer.beep(1175,0.1); 00094 } 00095 if (note=="e") { 00096 buzzer.beep(1319,0.1); 00097 } 00098 if (note=="f") { 00099 buzzer.beep(1397,0.1); 00100 } 00101 if (note=="g") { 00102 buzzer.beep(1568,0.1); 00103 } 00104 00105 if (note=="gb") { 00106 buzzer.beep(830,0.1); 00107 } 00108 if (note=="eb") { 00109 buzzer.beep(659,0.1); 00110 } 00111 if (note=="f#") { 00112 buzzer.beep(1480,0.1); 00113 } 00114 if (note=="w") { 00115 wait(0.05); 00116 } 00117 wait (0.2); //wait while the note plays. 00118 } 00119 00120 00121 int main() { 00122 popcorn(); 00123 }
Generated on Tue Jul 12 2022 14:12:55 by
1.7.2