/// mrfrozenpeak //// int freq[3][10] = { {150,200,300,400,600,800,1000,1200,1500,2000}, // defining the frequencies for different modes of piano {50,70,90,120,150,180,210,250,290,350} ,{500,800,1200,1500,2000,2500,3000,3500,4000,4500} }; int mode = 0; void setup() { pinMode(2,OUTPUT); // setup pin for speaker output pinMode(13,INPUT); pinMode(12,INPUT); pinMode(11,INPUT); pinMode(10,INPUT); // setup pin for ir sensor input pinMode(9,INPUT); pinMode(8,INPUT); pinMode(7,INPUT); pinMode(6,INPUT); pinMode(5,INPUT); pinMode(4,INPUT); pinMode(0,INPUT); // analog pin for touch sensor swicth // put your setup code here, to run once: // 200> } void loop() { int a1 = digitalRead(13); int a2 = digitalRead(12); int a3 = digitalRead(11); int a4 = digitalRead(10); int a5 = digitalRead(9); // taking all sensor inputs int a6 = digitalRead(8); int a7 = digitalRead(7); int a8 = digitalRead(6); int a9 = digitalRead(5); int a10 = digitalRead(4); int mode_update = analogRead(A0); // analog input for touch switch if(mode_update >500){ noTone(2); tone(2,500,300); // if touch switch is pressed, update value of mode and if mode is last mode convert it to frist mode if(mode<2){ mode++;} else{ mode = 0;} delay(2000); } if(a1==0){ tone(2,freq[mode][0],10); // simple conditional statements } if(a2==0){ tone(2,freq[mode][1],10); } if(a3==0){ tone(2,freq[mode][2],10); } if(a4==0){ tone(2,freq[mode][3],10); } if(a5==0){ tone(2,freq[mode][4]); } if(a6==0){ tone(2,freq[mode][5]); } if(a7==0){ tone(2,freq[mode][6]); } if(a8==0){ tone(2,freq[mode][7]); } if(a9==0){ tone(2,freq[mode][8]); } if(a10==0){ tone(2,freq[mode][9]); } if(a1==1 & a2==1 & a3==1 & a4==1 & a5==1 & a6==1 & a7==1 & a8==1 & a9==1 & a10==1){ // if all sensor inputs high, stop audio noTone(2); } //ton = ton+100; // put your main code here, to run repeatedly: }