Jacob Dahleen
/
I2CSong
Project for playing a song on 2 meeds sending notes over I2C
Diff: main.cpp
- Revision:
- 1:feca2dfd8753
- Parent:
- 0:db7b3841b98f
- Child:
- 2:c35c40bae96e
--- a/main.cpp Wed Feb 12 17:44:26 2014 +0000 +++ b/main.cpp Thu Feb 13 20:24:43 2014 +0000 @@ -1,6 +1,6 @@ #include "mbed.h" #include "C12832.h" -#include "music.h" +#include "mario.h" BusIn joy(p15,p12,p13,p16); DigitalIn fire(p14); @@ -34,47 +34,34 @@ 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]); + wait(.7*marioBeats[i]/12); } else{ - spkr.period(1/(2*notes[marioNotes[i]])); + spkr.period(1/(notes[marioNotes[i]])); spkr=.5; - wait(.7*marioBeats[i]); + wait(.7*marioBeats[i]/12); 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); + else + { + leds=joy; +#ifdef MASTER + if(up){ + + } + else if(down){ + + } +#elif + +#endif + } } } \ No newline at end of file