/* Flash trigger 2014 Ope Oladipo */ int mic = A3; //Initialize the mic int flashPin = 8; //initialize the flash pin int threshold = 400; void setup() { // the setup routine runs once when you press reset: Serial.begin(9600); // initialize serial communication at 9600 bits per second: pinMode(mic, INPUT); //set mic as input pinMode(flashPin, OUTPUT); //set flashpin as output digitalWrite(flashPin, LOW); //make sure the flashpin has no current initially } void loop() { // the loop routine runs over and over again forever: int micValue = analogRead(mic); // read the input pin: //Serial.println(micValue); //delay(70); // delay in between reads for stability if (micValue < threshold ) { Serial.println("sound"); digitalWrite(flashPin, HIGH); // flash goes off digitalWrite(flashPin, LOW); delay(1100); //for stability } }