Project for playing a song on 2 meeds sending notes over I2C

Dependencies:   C12832 mbed

Revision:
0:db7b3841b98f
Child:
1:feca2dfd8753
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 12 17:44:26 2014 +0000
@@ -0,0 +1,80 @@
+#include "mbed.h"
+#include "C12832.h"
+#include "music.h"
+
+BusIn joy(p15,p12,p13,p16);
+DigitalIn fire(p14);
+PwmOut spkr(p26);
+PwmOut red (p23);
+PwmOut green (p24);
+PwmOut blue (p25);
+C12832 lcd(p5, p7, p6, p8, p11);
+AnalogIn pot1(p19);
+AnalogIn pot2(p20);
+DigitalIn up(p15); 
+DigitalIn down(p12);
+
+BusOut leds(LED1,LED2,LED3,LED4);
+
+int main()
+{
+    float p1Voltage = 0;
+    float p2Voltage = 0;
+    float blueDC = 1;
+    red.period(0.001);
+    green.period(0.001);
+    blue.period(0.001);
+    red=1;
+    green=1;
+    blue=1;
+    
+    lcd.cls();
+    lcd.printf("hello world");
+    
+    while(1) {
+        if (fire) {
+            leds=0xf;
+            //start speaker code
+//            for (float i=2000.0; i<10000.0; i+=100) {
+//                spkr.period(1.0/i);
+//                spkr=0.5;
+//                wait(0.1);
+//            }
+//            spkr=0.0;
+            for(int i=0;i<(sizeof(marioNotes)/sizeof(NoteName));i++){
+                if(marioNotes[i] == R) {
+                    spkr=0.0;
+                    wait(.7*marioBeats[i]);
+                }
+                else{
+                    spkr.period(1/(2*notes[marioNotes[i]]));
+                    spkr=.5;
+                    wait(.7*marioBeats[i]);
+                    spkr=0.0;
+                }
+            }
+            spkr=0.0;
+            //end speaker code
+        } else {
+            leds=joy;
+        }
+        
+        //read potentiometers
+        p1Voltage = pot1.read();
+        p2Voltage = pot2.read();
+        //set LEDs based on pots and switch
+        red = 1-p1Voltage;
+        green = 1-p2Voltage;
+        if(up & blueDC >= .05)
+        {blueDC -= .05;}
+        if(down & blueDC <= .95)
+        {blueDC += .05;}
+        blue = blueDC;
+        //print pot values and blueDC
+        lcd.cls();
+        lcd.locate(0,0);
+        lcd.printf("Pot1 = %f\nPot2 = %f\nBlueDC = %f",p1Voltage, p2Voltage, blueDC);
+        
+        wait(0.1);
+    }
+}
\ No newline at end of file