pot to control flash delay

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.

Code Issues 0 Pull requests 0 Pulse Graphs
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 SENSOR_PIN 0
#define LED_PIN 13
#define STANDBY 0
#define ACTIVE 1
//#define POT_PIN 5
int mode = STANDBY;
int flashDelayMS = 0; //changed from LONG

void setup()

digitalWrite(LED_PIN, HIGH);

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);
Serial.println(flashDelayMS); //used to debug
digitalWrite(FLASH_TRIGGER_PIN, HIGH); // fire flash
mode = STANDBY;
digitalWrite(LED_PIN, HIGH);
Many thanks


Apologies for posting the code in the body of the text and not as an attachment.

Hi Dansky,
I am not sure how your set-up works!! In fact perhaps we should see your schematic first, otherwise we'll just be stabbing in the dark?

But I would put the pot ends between Pos & Neg with the wiper going to an analog input.

Some code to convert it or read it as a delay or delaymicros, this being the lag between sensing and firing the flash...

It can be good fun and you get some amazing pictures of drops of milk splashing!, balloons busting, breaking glass, etc..

Tell us more and show us..



many thanks Mel

set up is very simple

Sound sensor breakout board plugs into PIN 0

Flash output via PIN 7 through an opto-coupler.

Circuit works fine and can control SENSITIVITY and DELAY via code.

The problem comes when I try and code for the POT, which is connected corrected with the middle pin to PIN 5 (this is the part I would like some help with).

// are in front of POT code at mo as when removed a delay of .667s happens.

many thanks again