Cassa bluetooth con modulo wtv020sd-16p

Dependencies:   WTV020SD_Sound_Breakout_Library mbed

Fork of Progetto_finale_noLCD by Mattia Nicosia

main.cpp

Committer:
Mattinico
Date:
2016-11-26
Revision:
0:d760fe3f3304

File content as of revision 0:d760fe3f3304:

#include "mbed.h" 
#include "soundboard.h"
Serial pc (USBTX, USBRX);  
RawSerial hc05(D8, D2);
soundboard msb(D3, D5, D7, D9);//1, 7, 10, 15
//8GND, 4-5cassa, 163V3
DigitalOut l1(D15);
DigitalOut l2(D14);
DigitalOut l3(D12);

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_5);
   l1=1; l2=1; l3=0;
    while(1){
          
         if(hc05.readable ()){
             b=hc05.getc();
             switch (b){
                 case '-':{
                     pc.printf("MIN\n\r");
                     msb.setVolume(VOL_5-0x0002);
                    l1=1; l2=0; l3=0;
                     break;
                    }
                case '+':{
                 pc.printf("MAX\n\r");
                 msb.setVolume(VOL_5+0x0002);
                 l1=1; l2=1; l3=1;
                 break;
                }
                case 's':{
                 pc.printf("Volume 5\n\r");
                 msb.setVolume(VOL_5);
                 l1=1; l2=1; l3=0;
                 break;
                }
                
            }
            }
                    
         if(hc05.readable ()){
            a=hc05.getc();
            switch (a){
                case '1': {
                    pc.printf("Traccia 1\n\r");
                    msb.playAsync(0);
                    
                    break;
                    }
                case '2':{
                    pc.printf("Traccia 2\n\r");
                    msb.playAsync(1);
                    break;
                    }
                case '3':{
                    pc.printf("Traccia 3\n\r");
                    msb.playAsync(2);
                    break;
                    }
                case '4': {
                    pc.printf("Traccia 4\n\r");
                    msb.playAsync(3);
                    
                    break;
                    }
                case 'p': {
                    pc.printf("PAUSA\n\r");
                    msb.pause();
                    
                    break;
                    }
            }
        }
         
}  
}