nadiyah johnson
/
SongsAndLights
Plays songs and changes LED Color
main.cpp
- Committer:
- nadiyah
- Date:
- 2014-02-12
- Revision:
- 0:c6da9c77286d
- Child:
- 1:028b0f4df520
File content as of revision 0:c6da9c77286d:
#include "mbed.h" //#include "TextLCD.h" #include "mbed.h" PwmOut buzzer(p26); /*Table 4.3: Frequencies of notes used in tune Word/syllable Musical note Frequency (Hz) Beats Oran- E 659 1 ges C# 554 1 and E 659 1 le- C# 554 1 mons, A 440 1 say B 494 ½ the C# 554 ½ bells D 587 1 of B 494 1 St E 659 1 Clem- C# 554 1 ent’s A 440 2 Analog Output 73*/ PwmOut r(p23), g(p24), b(p25); Serial usbSerial(USBTX,USBRX); AnalogIn pot(p19); AnalogIn pot1(p20); DigitalIn JS(p14); //frequency array //float frequency[]={659,554,659,554,440,494,554,587,494,659,554,440}; #include "C12832.h" C12832 lcd(p5, p7, p6, p8, p11); float frequency[]={392.00,659,659,587,659,392.00,392.00,440.00,440.00,523.25,440.00,440,392.00,392.00,392.00,659,659,587,659,392.00,392.00,440.00,440.00,392.00,261.63,659,587,261.63}; float beat[]={1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2}; //beat array int main() { while (1) { while(!JS){ r=pot.read(); g=pot1.read(); } while(JS){ for (int i=0;i<=29;i++) { buzzer.period(1/(2*frequency[i])); // set PWM period buzzer=0.5; // set duty cycle wait(0.7*beat[i]); // hold for beat period lcd.cls(); lcd.locate(0,3); lcd.printf("Jesus Loves Me"); r=pot.read(); g=pot1.read(); } while(!JS){ r=pot.read(); g=pot1.read(); } } /////color change ///lcd } /* while(1){ r=pot.read(); g=pot1.read(); }*/ }