does not fire if quick

Hi. I am a newbie in Arduino. I am fighting with this issue for quite some time. I am trying to implement a classic Arduino project: flash triggered by a sensor. I have a laser that shines on a DFRobot light sensor, when laser light is blocked (value becomes more than the threshold), Arduino sends signal that goes through an optoisolator and triggers a Canon flash. (similar to mrichardson23's project from Make magazine) . For now there is no camera. Everything works - I photographed a Coke can falling into an aquarium (without fish) - looks good! But I wanted to photograph a much faster event - a whip overcoming sound barrier. My setup does not work for fast traveling objects, even a finger quickly moved through the beam does not fire the flash. Below is my code. Please help. P.S. My threshold is just over the light level when the laser shines.

int LASER_PIN = 5; int FLASH_PIN = 4; int SENSOR_PIN = 0; int SENSOR_THRESHOLD = 430;

void setup() { pinMode(FLASH_PIN, OUTPUT); digitalWrite(FLASH_PIN, LOW); pinMode(LASER_PIN, OUTPUT); digitalWrite(LASER_PIN, HIGH); } void loop() { int sensorVal; sensorVal = analogRead(SENSOR_PIN); if (sensorVal > SENSOR_THRESHOLD) //If we sense a shadow: { digitalWrite(FLASH_PIN, HIGH); // fire flash delay(10); digitalWrite(FLASH_PIN, LOW); } }

analogRead() is very slow. Figure out how to bias your sensor to provide a 3V or high signal so you can use a digitalRead() instead. digitalRead() is also kind of slow, so at that point you could use direct port manipulation.

Thanks. I'll try.

Does this light sensor use a CdS cell? If so you should expect a slow response.

An IR detector (phototransistor) would work much better.

It has Cds Photoresistor as a light sensitive element. I recently got IR barrier kit - I probably could use it! Though I am still uncertain what kind of IR sensor it uses.

I used the phototransistor and it works!!! Thanks a lot! I'll try it on something faster than a piece of wire in my fingers.