Go Down

Topic: Trying to optimize a flash trigger (Read 1 time) previous topic - next topic

Papa G

What is the purpose of the Arduino? You could speed the response time up by removing it.

Perhaps you are using it to insert delays between the time the LASER beam is broken and the time the flash occurs. If that is the case, you will need to post your code before anyone can suggest ways to optimize it.


It might be quicker reacting and more consistent if you could use a digital pin in interrupt mode to read a optical photo detector with logic output.


I chose this project and am using an arduino because I am interested in photography and also thought it would be really fun to learn how to use an arduino.  I think the trigger is pretty fast as is (the colored vials were photographed before they even hit the water).  But since this is my first project, I am really interested in how I could wire/ program things better, so that I can use the knowledge for future projects. 
Riva- Thanks for the suggestion.  Right now though I am not sure what you mean (just got home and haven't looked into it yet).
Also I was wondering, would using serial.println cause any delays in the process?
Below is my code.  Thanks!

Code: [Select]

/* Laser triggered flash using pot for delay

int photocellPin = A0;     //photocell and 10k pulldown resistor
int photocellReading;      //value of photocell reading
int LEDpin = 11;           //activate optoisolator
int laser = 3;             //activate transistor, complete current to laser
int delayPot = A5;         //get value from potentiometer to adjust delay from 0-1023 ms, gets recorded to delatTimer

int sensorValue = 0;       //phototransistor sensor value
int sensorMin = 1023;      //minimum sensor value
int sensorMax = 0;         //maxiumum sensor value

int delayTimer = 0;             //delay timing of flash

void setup(void)

   pinMode(13, OUTPUT);   //LED light, on when calibrating
   pinMode(11, OUTPUT);   //Power to optoisolator to trigger FLASH OR ACTION

   digitalWrite(11, LOW);     //turn off current to optoisolator
   digitalWrite(13, HIGH);    //turn on Arduino LED while measuring high/low light
   digitalWrite(laser, HIGH);   //turn on laser
   while (millis() < 5000)      //during the first 5 seconds determine light range         
       sensorValue = analogRead(photocellPin);     
       if (sensorValue >sensorMax)       //determine max sensor value
          sensorMax = sensorValue;
       if (sensorValue < sensorMin)      //determine min sensor value
          sensorMin = sensorValue;
    digitalWrite(13, LOW);                   //turn off LED, indicates calibration is complete
    Serial.print("Max sensor Value = ");     //print max sensor value
    Serial.print("Min sensor Value = ");     //print min sensor value
    sensorMin = sensorMin - 2;               //adjust min sensor value  TRY REMOVING
    Serial.print("New sensorMin");

void loop()

   sensorValue = analogRead(photocellPin);    //read photocellPin;
   delayTimer = analogRead(delayPot);         //get delay before triggering flash from pot value
   Serial.println(delayTimer);                //print delay taken from pot
   if (sensorValue < sensorMin)                       //if light to phototransistor is reduced, begin flash procedure
       Serial.print("FLASH Analog reading =  ");      //display sensorValue
       digitalWrite(laser, LOW);                      //turn off laser so beam is not in photo
       Serial.print("Now delaying");                  //delay from potentiometer setting
       digitalWrite(11, HIGH);       //current to optoisolator, trigger flash
       delay(100);                   //keep current going to make sure flash is triggered
       digitalWrite(11, LOW);        //turn off flash trigger
       digitalWrite(laser, HIGH);    //turn laser back on
       Serial.println("READY");      //ready for next photo


Oh, and HazardsMind- you are right.  I checked my wiring, and did misdraw the wires/resistor in my diagram.  Thanks!


Serial.println will most certainly slow it down.
You can use it for maybe debugging the system, but having all of them in will slow it down.
Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Go Up