Cassa bluetooth con modulo wtv020sd-16p

Dependencies:   WTV020SD_Sound_Breakout_Library mbed

Fork of Progetto_finale_noLCD by Mattia Nicosia

Committer:
Mattinico
Date:
Sat Nov 26 13:57:50 2016 +0000
Revision:
0:d760fe3f3304
k

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mattinico 0:d760fe3f3304 1 #include "mbed.h"
Mattinico 0:d760fe3f3304 2 #include "soundboard.h"
Mattinico 0:d760fe3f3304 3 Serial pc (USBTX, USBRX);
Mattinico 0:d760fe3f3304 4 RawSerial hc05(D8, D2);
Mattinico 0:d760fe3f3304 5 soundboard msb(D3, D5, D7, D9);//1, 7, 10, 15
Mattinico 0:d760fe3f3304 6 //8GND, 4-5cassa, 163V3
Mattinico 0:d760fe3f3304 7 DigitalOut l1(D15);
Mattinico 0:d760fe3f3304 8 DigitalOut l2(D14);
Mattinico 0:d760fe3f3304 9 DigitalOut l3(D12);
Mattinico 0:d760fe3f3304 10
Mattinico 0:d760fe3f3304 11 int main() {
Mattinico 0:d760fe3f3304 12
Mattinico 0:d760fe3f3304 13 char a;
Mattinico 0:d760fe3f3304 14 char b;
Mattinico 0:d760fe3f3304 15 pc.baud(9600); // setto il baud rate della porta seriale pc
Mattinico 0:d760fe3f3304 16 hc05.baud(9600);// setto il baud rate della porta rawserial hc05
Mattinico 0:d760fe3f3304 17 msb.setVolume(VOL_5);
Mattinico 0:d760fe3f3304 18 l1=1; l2=1; l3=0;
Mattinico 0:d760fe3f3304 19 while(1){
Mattinico 0:d760fe3f3304 20
Mattinico 0:d760fe3f3304 21 if(hc05.readable ()){
Mattinico 0:d760fe3f3304 22 b=hc05.getc();
Mattinico 0:d760fe3f3304 23 switch (b){
Mattinico 0:d760fe3f3304 24 case '-':{
Mattinico 0:d760fe3f3304 25 pc.printf("MIN\n\r");
Mattinico 0:d760fe3f3304 26 msb.setVolume(VOL_5-0x0002);
Mattinico 0:d760fe3f3304 27 l1=1; l2=0; l3=0;
Mattinico 0:d760fe3f3304 28 break;
Mattinico 0:d760fe3f3304 29 }
Mattinico 0:d760fe3f3304 30 case '+':{
Mattinico 0:d760fe3f3304 31 pc.printf("MAX\n\r");
Mattinico 0:d760fe3f3304 32 msb.setVolume(VOL_5+0x0002);
Mattinico 0:d760fe3f3304 33 l1=1; l2=1; l3=1;
Mattinico 0:d760fe3f3304 34 break;
Mattinico 0:d760fe3f3304 35 }
Mattinico 0:d760fe3f3304 36 case 's':{
Mattinico 0:d760fe3f3304 37 pc.printf("Volume 5\n\r");
Mattinico 0:d760fe3f3304 38 msb.setVolume(VOL_5);
Mattinico 0:d760fe3f3304 39 l1=1; l2=1; l3=0;
Mattinico 0:d760fe3f3304 40 break;
Mattinico 0:d760fe3f3304 41 }
Mattinico 0:d760fe3f3304 42
Mattinico 0:d760fe3f3304 43 }
Mattinico 0:d760fe3f3304 44 }
Mattinico 0:d760fe3f3304 45
Mattinico 0:d760fe3f3304 46 if(hc05.readable ()){
Mattinico 0:d760fe3f3304 47 a=hc05.getc();
Mattinico 0:d760fe3f3304 48 switch (a){
Mattinico 0:d760fe3f3304 49 case '1': {
Mattinico 0:d760fe3f3304 50 pc.printf("Traccia 1\n\r");
Mattinico 0:d760fe3f3304 51 msb.playAsync(0);
Mattinico 0:d760fe3f3304 52
Mattinico 0:d760fe3f3304 53 break;
Mattinico 0:d760fe3f3304 54 }
Mattinico 0:d760fe3f3304 55 case '2':{
Mattinico 0:d760fe3f3304 56 pc.printf("Traccia 2\n\r");
Mattinico 0:d760fe3f3304 57 msb.playAsync(1);
Mattinico 0:d760fe3f3304 58 break;
Mattinico 0:d760fe3f3304 59 }
Mattinico 0:d760fe3f3304 60 case '3':{
Mattinico 0:d760fe3f3304 61 pc.printf("Traccia 3\n\r");
Mattinico 0:d760fe3f3304 62 msb.playAsync(2);
Mattinico 0:d760fe3f3304 63 break;
Mattinico 0:d760fe3f3304 64 }
Mattinico 0:d760fe3f3304 65 case '4': {
Mattinico 0:d760fe3f3304 66 pc.printf("Traccia 4\n\r");
Mattinico 0:d760fe3f3304 67 msb.playAsync(3);
Mattinico 0:d760fe3f3304 68
Mattinico 0:d760fe3f3304 69 break;
Mattinico 0:d760fe3f3304 70 }
Mattinico 0:d760fe3f3304 71 case 'p': {
Mattinico 0:d760fe3f3304 72 pc.printf("PAUSA\n\r");
Mattinico 0:d760fe3f3304 73 msb.pause();
Mattinico 0:d760fe3f3304 74
Mattinico 0:d760fe3f3304 75 break;
Mattinico 0:d760fe3f3304 76 }
Mattinico 0:d760fe3f3304 77 }
Mattinico 0:d760fe3f3304 78 }
Mattinico 0:d760fe3f3304 79
Mattinico 0:d760fe3f3304 80 }
Mattinico 0:d760fe3f3304 81 }