
PROGRAMMA FINALE
Dependencies: TextLCD WTV020SD_Sound_Breakout_Library mbed
Diff: main.cpp
- Revision:
- 0:69cd3cb5e75f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 31 18:36:30 2017 +0000 @@ -0,0 +1,79 @@ +#include "mbed.h" +#include "TextLCD.h" +#include "soundboard.h" +Serial pc (SERIAL_TX, SERIAL_RX); +RawSerial hc05(D8, D2); +TextLCD lcd(D12, D11, D6, D4, D14, D15);// rs, e, d4-d7 +soundboard msb(D3,D5,D7,D9);//1, 7, 10, 15 +//8GND, 4-5cassa, 163V3 + +int main() { + char a; + char b; + pc.baud(9600); // setto il baud rate della porta seriale pc + hc05.baud(9600);// setto il baud rate della porta rawserial hc05 + msb.setVolume(VOL_7); + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Cassa\n"); + while(1){ + if(hc05.readable ()){ + a=hc05.getc(); + + switch (a){ + case '1': { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Song: Narcos"); + msb.playAsync(0); + break; + } + case '2':{ + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Song: Aria"); + msb.playAsync(1); + break; + } + case '3':{ + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Song: Simon says"); + msb.playAsync(2); + break; + } + case '4': { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Song: Curnuton"); + msb.playAsync(3); + break; + } + } + } + if(hc05.readable ()){ + b=hc05.getc(); + switch (b){ + case '-':{ + lcd.locate(0,1); + lcd.printf("Volume: 20/100"); + msb.setVolume(VOL_5-0x0002); + break; + } + case '+':{ + lcd.locate(0,1); + lcd.printf("Volume: 90/100"); + msb.setVolume(VOL_4+0x0002); + break; + } + case '/':{ + lcd.locate(0,1); + lcd.printf("Volume: 60/100"); + msb.setVolume(VOL_4); + break; + } + + } + } +} +} \ No newline at end of file