I am very new to arduino and am making a flash trigger based on the M Richardson sketch.
All has gone well until I tried to add a pot to control delay between detection of the sensor and the firing of the flash, with or without the pot connected.
without the pot I can delay using the sketch
when I add the pot code and serial print their is an automatic delay of about 600ms.
I would like to have a delay from 0 to 1000ms.
Any help would be appreciated. The slightly modified sketch is below.
/*mrichardson23/Arduino-Audio-Flash-Trigger
Code Issues 0 Pull requests 0 Pulse Graphs
Arduino-Audio-Flash-Trigger/Arduino-Audio-Flash-Trigger.pde
c160d73 on 4 Nov 2010
mrichardson23 Added worklight relay & more comments
56 lines (50 sloc) 1.75 KB
Audio camera trigger by Matt Richardson
This is a basic sound-detecting camera & flash trigger for Arduino.
Use a piezo element for the sensor (see http://www.arduino.cc/en/Tutorial/KnockSensor)
Use opto isolators (aka optocouplers) for the flash and camera triggers
Camera must be in BULB mode for shutter release to work
*/
#define FLASH_TRIGGER_PIN 7
#define SENSOR_PIN 0
#define LED_PIN 13
#define STANDBY 0
#define ACTIVE 1
//#define POT_PIN 5
#define SENSOR_THRESHOLD 200
int mode = STANDBY;
int flashDelayMS = 0; //changed from LONG
void setup()
{
pinMode(FLASH_TRIGGER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
Serial.begin(9600);
}
void loop() {
{
mode = ACTIVE;
digitalWrite(LED_PIN, LOW); // show we're ready
}
{
}
if ((mode == ACTIVE) && (analogRead(SENSOR_PIN) > SENSOR_THRESHOLD)) //
{
//If we're in ACTIVE mode and we sense a pop:
//int flashDelayMS = analogRead(POT_PIN);
delay(flashDelayMS);
Serial.println(flashDelayMS); //used to debug
digitalWrite(FLASH_TRIGGER_PIN, HIGH); // fire flash
delay(50);
digitalWrite(FLASH_TRIGGER_PIN, LOW);
mode = STANDBY;
digitalWrite(LED_PIN, HIGH);
delay(3000);
}
}
Many thanks
Jon