// checks to see if there is sound and if there is turns on red light
//REM make sure you check the level on the potentiometer if it doesn't work!!
int micPin = 6; // Mic connected to pin 6
int micVal = HIGH; //HIGH is no sound, LOW is sound
void setup ()
{
Serial.begin(9600);
pinMode(12, OUTPUT); //red led for sound
pinMode (11, OUTPUT); // green led for silence
pinMode (micPin, INPUT) ; //Set pin for input
}
void loop ()
{
micVal = digitalRead (micPin) ; // senses sound
if (micVal == HIGH ) // There is sound!!!
{
Serial.println ("silence");// sends 'silence' to printer
digitalWrite(11, HIGH);//turns on green LED
delay (5);
digitalWrite (11, LOW);// turns off green LED
} else { Serial.println ("sound");// sends 'sound' to prinetr
digitalWrite(12, HIGH);//turns on red LED
delay (5000);
digitalWrite (12, LOW);// turns off red LED
}
}
Comments