/* High Speed Photo July 2011 Nico */ #define ANALOG_IN 0 // Analog input pin that the mic is attached to #define DIGITAL_OUT 5 // Digital output pin that the relay is attached to #define ANALOG_THRESHOLD 512 //#define DBG_FLASH int theend = 0; void setup() { pinMode(DIGITAL_OUT, OUTPUT); digitalWrite(DIGITAL_OUT, LOW); #ifdef DBG_FLASH Serial.begin(9600); #endif } void loop() { // read the analog in value: int sensorValue = analogRead(ANALOG_IN); // 0 - 1024 if (!theend && (sensorValue > ANALOG_THRESHOLD)) { digitalWrite(DIGITAL_OUT, HIGH); delay(50); digitalWrite(DIGITAL_OUT, LOW); theend = 1; // will not trigger until reset button is pressed. } #ifdef DBG_FLASH char buf[64]; sprintf(buf, "sensor value %d", sensorValue); Serial.println(buf); #endif }