PROGRAMMA FINALE

Dependencies:   TextLCD WTV020SD_Sound_Breakout_Library mbed

main.cpp

Committer:
Mattinico
Date:
2017-01-31
Revision:
0:69cd3cb5e75f

File content as of revision 0:69cd3cb5e75f:

#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;
                }
                
            }
            }    
}  
}