Analogue input change as switch.Code help

Hi all new to arduino and programming hoping to get some help writing some simple code.Well not to me obviously:)

I am trying to make a camera flash trigger for high speed photography using a photo-transistor, red laser an arduino and a strobe flash head. In average light the photo-transistor circuit i am using, analogue input changes roughly from 700-950(serial read) when in shadow. Once a noticeable change(variable) is detected i need a delay(variable) and an output pin to trigger an opto-isolator which will in turn trigger the flash then reset in a certain amount of time(variable). The actual triggering does not need to be fast between flashes as all shots are taken in darkness with a high speed single flash. 2 second recycle time.

I hope someone can explain how to do this easily as I am struggling with the programming language at the moment.

First, if you want it fast, don't use analogRead. Each call takes about 100us.

Can you post your code, and maybe then we've got something to talk about.

Your code could be a simple as something like:

while (digitalRead (triggerPin));
delayMicroseconds (delayTime);
digitalWrite (optoPin, HIGH);
delayMicroseconds (triggerTimeTime);
digitalWrite (optoPin, LOW);

It doesn't need to be super fast ,100us will be fine for this as a delay will usually used anyway and I haven't written any code as I'm still retarded in the programming department..

while (analogRead (triggerPin) > triggerThreshold);  // (or maybe less than)
delayMicroseconds (delayTime);
digitalWrite (optoPin, HIGH);
delayMicroseconds (triggerTime);
digitalWrite (optoPin, LOW);

Cheers AWOL i came up with this. I change the circuit a little and now analogue input reads from 25 in average light to around 400 when blocked. It's my first attempt at programming and it's probably wrong but please bear with me. :~ :~

  //Light sensitive flash trigger using a phototransistor 
  
  //when sensor is momentarily blocked of light, analogue read
  //increases which will output 5v to an optocoupler for 1 second
  //then delays for 5 seconds.


  //optocoupler + connected to digital pin 13
  //phototransistor connected to analogue pin 0
  
#define optoPin 13
#define triggerPin A0

#define delayTime 0
#define triggerThreshold 150
#define triggerTime 1000

void setup()
{
  //initialize the digital pin 13 as an output.
  pinMode(optoPin, OUTPUT);
  //initialize analogue input A0 as an input.
  pinMode(triggerPin, INPUT);
}

void loop()
{
  while (analogRead (triggerPin) > triggerThreshold);
  delayMicroseconds (delayTime);
  digitalWrite (optoPin, HIGH);
  delayMicroseconds (triggerTime);
  digitalWrite (optoPin, LOW);
  delay (5000);
}
 //initialize analogue input A0 as an input.
  pinMode(triggerPin, INPUT);

One small thing; the analogue inputs are by default, well, inputs. All this line does is turn it briefly into a digital input. You don't need that line.

If you want a zero microseconds delay, don't call "delayMicroseconds"

delayMicroseconds (triggerTime);

Your header comment says turn on the opto for one second, but the value of triggerTime is 1000, so it only delays for one millisecond (still, enough time to trigger a flash)

(OK, sorry, that was more than "one thing")

Thanks AWOL this should be correct now.

  //Light sensitive flash trigger using a phototransistor 
  
  //when sensor is momentarily blocked of light, analogue read
  //increases which will output 5v to an optocoupler for 1 second
  //then delays for 5 seconds.


  //optocoupler + connected to digital pin 13
  //phototransistor connected to analogue pin 0
  
#define optoPin 13
#define triggerPin A0

#define delayTime 0
#define triggerThreshold 150
#define triggerTime 1000

void setup()
{
  //initialize the digital pin 13 as an output.
  pinMode(optoPin, OUTPUT);
}

void loop()
{
  while (analogRead (triggerPin) > triggerThreshold);
  delay (delayTime);
  digitalWrite (optoPin, HIGH);
  delay (triggerTime);
  digitalWrite (optoPin, LOW);
  delay (5000);
}