segunda-feira, 11 de junho de 2012

Projeto - Código Piano.ino

    
int LDR1,LDR2,LDR3,LDR4,LDR5,LDR6,LDR7;
float VLDR1,VLDR2,VLDR3,VLDR4,VLDR5,VLDR6,VLDR7;
    
void setup(){
DDRD = DDRD | B11011100;
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(5, INPUT);
pinMode(13,OUTPUT);
digitalWrite(13, HIGH);
pinMode(12,OUTPUT);
digitalWrite(12, HIGH); 
pinMode(11,OUTPUT);
digitalWrite(11, HIGH);
pinMode(10,OUTPUT);
digitalWrite(10, HIGH); 
pinMode(9,OUTPUT);
digitalWrite(9, HIGH); 
pinMode(7,OUTPUT);
digitalWrite(7, HIGH);
pinMode(6,OUTPUT);
digitalWrite(6, HIGH); 
}
    
void loop(){
LDR1 = analogRead(A0);
VLDR1=LDR1*5.0000000/1024;
Serial.println(VLDR1);
while(VLDR1>=4.0){
  LDR1 = analogRead(A0);
  VLDR1=LDR1*5.0000000/1024;
  Serial.println(VLDR1);
  tone(8,262);
}
if(VLDR1<4.0){
  noTone(8);
}
LDR2 = analogRead(A1);
VLDR2=LDR2*5.0000000/1024;
while(VLDR2>=4.0){
  LDR2 = analogRead(A1);
  VLDR2=LDR2*5.0000000/1024;
  tone(8,294);
}
if(VLDR2<4.0){
  noTone(8);
}
LDR3 = analogRead(A2);
VLDR3=LDR3*5.0000000/1024;
while(VLDR3>=4.0){
  LDR3 = analogRead(A2);
  VLDR3=LDR3*5.0000000/1024;
  tone(8,329);
}
if(VLDR3<4.0){
  noTone(8);
}
LDR4 = analogRead(A3);
VLDR4=LDR4*5.0000000/1024;
while(VLDR4>=4.0){
  LDR4 = analogRead(A3);
  VLDR4=LDR4*5.0000000/1024;
  tone(8,349);
}
if(VLDR4<4.0){
  noTone(8);
}
LDR5 = analogRead(A4);
VLDR5=LDR5*5.0000000/1024;
while(VLDR5>=4.0){
  LDR5 = analogRead(A4);
  VLDR5=LDR5*5.0000000/1024;
  tone(8,392);
}
if(VLDR5<4.0){
  noTone(8);
}
LDR6 = analogRead(A5);
VLDR6=LDR6*5.0000000/1024;
while(VLDR6>=4.0){
  LDR6 = analogRead(A5);
  VLDR6=LDR6*5.0000000/1024;
  tone(8,440);
}
if(VLDR6<4.0){
  noTone(8);
}
}

Nenhum comentário:

Postar um comentário