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.

/*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

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

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..

Regards

Mel.

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

Jon