David Styles
/
popcorn
The popcorn song on 1 wire. Just add a piezo buzzer on p23 !
main.cpp
- Committer:
- DaveStyles
- Date:
- 2011-05-20
- Revision:
- 0:a0cac22ff2e7
File content as of revision 0:a0cac22ff2e7:
#include "mbed.h" #include "beep.h" Beep buzzer(p23); DigitalOut myled(LED1); void play(char* note); void popcorn() { play("e"); play("d"); play("e"); play("c"); play("gb"); play("c"); play("eb"); play("w"); play("e"); play("d"); play("e"); play("c"); play("gb"); play("c"); play("eb"); play("w"); play("e"); play("f#"); play("g"); play("f#"); play("g"); play("e"); play("f#"); play("e"); play("f#"); play("d"); play("e"); play("d"); play("e"); play("d"); play("e"); play("w"); play("e"); play("d"); play("e"); play("c"); play("gb"); play("c"); play("eb"); play("w"); play("e"); play("d"); play("e"); play("c"); play("gb"); play("c"); play("eb"); play("w"); play("e"); play("f#"); play("g"); play("f#"); play("g"); play("e"); play("f#"); play("e"); play("f#"); play("d"); play("e"); play("d"); play("e"); play("d"); play("g"); } void play(char* note) { if (note=="a") { buzzer.beep(880,0.1); } if (note=="b") { buzzer.beep(987,0.1); } if (note=="c") { buzzer.beep(1024,0.1); } if (note=="d") { buzzer.beep(1175,0.1); } if (note=="e") { buzzer.beep(1319,0.1); } if (note=="f") { buzzer.beep(1397,0.1); } if (note=="g") { buzzer.beep(1568,0.1); } if (note=="gb") { buzzer.beep(830,0.1); } if (note=="eb") { buzzer.beep(659,0.1); } if (note=="f#") { buzzer.beep(1480,0.1); } if (note=="w") { wait(0.05); } wait (0.2); //wait while the note plays. } int main() { popcorn(); }