Controlando LED pelo valor captado de um microfone
*/
int sensorPin = A8; // pin MIC
int ledPin = 26; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
Serial.println(sensorValue);
if ( sensorValue == 253 )
delay(sensorValue);
digitalWrite(ledPin, HIGH);
delay(5000);
digitalWrite(ledPin, LOW);
// stop the program for
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for
delay(sensorValue);
}
0 comments:
Postar um comentário