Jacob Dahleen
/
I2CSong
Project for playing a song on 2 meeds sending notes over I2C
main.cpp
- Committer:
- jad19925
- Date:
- 2014-02-13
- Revision:
- 3:eb63ba24e2bb
- Parent:
- 2:c35c40bae96e
- Child:
- 4:bd0675c58f5e
File content as of revision 3:eb63ba24e2bb:
#include "mbed.h" #include "C12832.h" #include "mario.h" #define MASTER //#define SLAVE BusIn joy(p15,p12,p13,p16); DigitalIn fire(p14); PwmOut spkr(p26); C12832 lcd(p5, p7, p6, p8, p11); DigitalIn up(p15); DigitalIn down(p12); BusOut leds(LED1,LED2,LED3,LED4); I2C i2cPort(p9,p10); char note; char length; const int masterAddress = 0x61; const int slaveAddress = 0x60; 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; for(int i=0;i<(sizeof(marioNotes)/sizeof(NoteName));i++){ if(marioNotes[i] == R) { spkr=0.0; wait(.7*marioBeats[i]/12); } else{ spkr.period(1/(notes[marioNotes[i]])); spkr=.5; wait(.7*marioBeats[i]/12); spkr=0.0; } } spkr=0.0; //end speaker code } else { leds=joy; #ifdef MASTER if(up) {//master sends its song to slave } else if(down) {//slave should send it's song to master } #elif SLAVE #endif } } }