segunda-feira, 11 de junho de 2012

Código-Fonte Final


int LDR[12];

void setup () {
  
   Serial.begin(9600);
   pinMode(8, OUTPUT);
   pinMode(9, OUTPUT); 
   pinMode(10, OUTPUT);  
   pinMode(A1, INPUT);
   pinMode(A2, INPUT);
   pinMode(A3, INPUT);
   pinMode(A4, INPUT);
   pinMode(13, OUTPUT);
   pinMode(6, OUTPUT);
   pinMode(7, OUTPUT);
}

void loop () {

    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    LDR[0] = analogRead (A0);

    digitalWrite(8, HIGH);
    LDR[1] = analogRead (A0);

    digitalWrite(8, LOW);
    digitalWrite(9, HIGH);
    LDR[2] = analogRead (A0);

    digitalWrite(8, HIGH);
    LDR[3] = analogRead (A0);

    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    LDR[4] = analogRead (A0);

    digitalWrite(8, HIGH);
    LDR[5] = analogRead (A0);

    digitalWrite(8, LOW);
    digitalWrite(9, HIGH);
    LDR [6] = analogRead (A0);

    digitalWrite(8, HIGH);
    LDR[7] = analogRead (A0);


    LDR[8] = analogRead (A1);
    LDR[9] = analogRead (A2);

    LDR[10] = analogRead (A3);
    LDR[11] = analogRead (A4);
  
  {

if(LDR[11] >= 800){
  digitalWrite(6, HIGH);
  tone(13, 110);
    if (LDR[8] >= 850){
      tone (13, 147);
    }
      else if (LDR[4] >= 850){
        tone(13, 139);
      }
        else if (LDR[3] >= 850){
          tone( 13, 131);
        }
          else if (LDR[2] >= 850){
            tone(13, 124);
          }
          else if (LDR[5] >= 850){
            tone (13, 117);
            }
}
else if (LDR[10] >= 850){
    digitalWrite(7, HIGH);
    tone(13, 82);
      
if (LDR[7] >= 800){
      tone(13, 110);
    }
      else if(LDR[9] >= 800){
        tone(13, 104);
      }
        else if(LDR[0] >= 800){
          tone(13, 98);
        }
          else if(LDR[6] >= 800){
            tone(13, 93);
          }
            else if(LDR[1] >= 800){
              tone(13, 87);
            }
}

else{
  noTone(13);
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
}


 Serial.print(LDR[0]);
 Serial.print("    ");
 Serial.print(LDR[1]);
 Serial.print("    ");
 Serial.print(LDR[2]);
 Serial.print("    ");
 Serial.print(LDR[3]);
 Serial.print("    ");
 Serial.print(LDR[4]);
 Serial.print("    ");
 Serial.print(LDR[5]);
 Serial.print("    ");
 Serial.print(LDR[6]);
 Serial.print("    ");
 Serial.print(LDR[7]);
 Serial.print("    ");
 Serial.print(LDR[8]);
 Serial.print("    ");
 Serial.print(LDR[9]);
 Serial.print("    ");
 Serial.print(LDR[10]);
 Serial.print("    ");
 Serial.print(LDR[11]);
 Serial.print("    ");
    
    
  }
  
  
  Serial.println(); // imprime em linhas

delay(90);

}
    
    
    
    

Nenhum comentário:

Postar um comentário