#include "melody.h"
int light1= A0;
int light2= A1;
int light3= A2;
int light4= A3;
int light5= A4;
int light6= A5;
int light7= 5;
int light8= 6;
int melody[]={c,d,e,f,g,a,b,c5};
int sound;
void setup(){
pinMode(11,OUTPUT);
Serial.begin(9600);
}
void loop(){
int reading1=analogRead(light1);
int reading2=analogRead(light2);
int reading3=analogRead(light3);
int reading4=analogRead(light4);
int reading5=analogRead(light5);
int reading6=analogRead(light6);
Serial.print(reading1);
Serial.print(" ");
Serial.print(reading2);
Serial.print(" ");
Serial.print(reading3);
Serial.print(" ");
Serial.print(reading4);
Serial.print(" ");
Serial.print(reading5);
Serial.print(" ");
Serial.println(reading6);
delay(500);
analogWrite(11,sound);
if(reading1<800){
tone(4 , c, 1000/4);
delay(100);
}
}
if(reading2<800){
tone(4,d, 1000/4);
delay(100);
}
}
if(reading3<800){
tone(4,e, 1000/4);
delay(100);
}
}
if(reading4<800){
tone(4,f, 1000/4);
delay(100);
}
}
if(reading5<800){
tone(4,g, 1000/4);
delay(100);
}
}
if(reading6<800){
tone(4,a, 1000/4);
delay(100);
}
delay(250);
}
이렇게 코드를 짰는데 소리가 한번만 나게 할 방법 머없나요???
|