I'm trying to use an ultrasonic rangefinder (SR-04) with an arduino Uno to trigger a camera shutter release only once for a given amount of time for each instance something passes in front. I have made it as far as triggering the camera from the basic rangefinder examples out there, but since the rangefinder is on a loop detecting things, it triggers the camera each time it reads the presence of an object. I am thinking that if I can make the camera trigger portion of the code somehow reset by the High or Low state of the rangefinder reading, that might do the trick, but I can't seem to understand how to write that!
Please forgive me if this is too basic, but I am new to arduino and have been searching forums and google/trying things for weeks to no avail. Thank you!
Project help camera triggering with rangefinder
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 2
- Joined: Sun Apr 07, 2013 12:56 pm
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Project help camera triggering with rangefinder
You need to add an IF statement that checks that a certain number of MILLIS have passed since the last shot. When the shot is taken record millis() then next time through the loop if millis is not bigger than the stored value just fall through the loop. You might also add a pause for a set amount of the time.
-
- Posts: 2
- Joined: Sun Apr 07, 2013 12:56 pm
Re: Project help camera triggering with rangefinder
Thanks for the reply! I will try that. Another complicating factor is that I wish the camera to trigger only once if an object sits in front of the camera for a while. I was thinking some kind of switching dependent upon high-low state, but again I am lost on the coding...
To clarify my aims: the ultimate goal of this project is to take a single photo of train cars as they pass. but since they are at different speeds and sometimes will be stopped completely for a bit, that means I need the camera trigger coding to be "reset" each time there is a gap between cars.
To clarify my aims: the ultimate goal of this project is to take a single photo of train cars as they pass. but since they are at different speeds and sometimes will be stopped completely for a bit, that means I need the camera trigger coding to be "reset" each time there is a gap between cars.
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Project help camera triggering with rangefinder
Have you tested the rangefinder in the real world to see if it can see the space between cars of a moving train? you can write code that will see an object, take a picture and test to see if the object has moved before resetting to take another. As you learn more about just what you want the project to do and can put that into precise words you will have an outline of what your code needs to be, it's a process that will evolve over time.
Please be positive and constructive with your questions and comments.