Pages: [1]   Go Down
Author Topic: does not fire if quick  (Read 501 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
   }
}
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks. I'll try.
Logged

Dubuque, Iowa, USA
Offline Offline
Faraday Member
**
Karma: 49
Posts: 2544
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

An IR detector (phototransistor) would work much better.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: