Hello, I am trying to build a camera trigger using a bicycle odometer so I can automatically take photos at a given distance. I use the photos with a GPS track to geo-tag them so I can put them in Google Maps. I am currently using a time lapse function but this is not working very well for going up and down hill, I want to make something that is not affected by speed.
I am planning to hack a cheap speedometer/odometer which is already set up to use a magnet and a reed switch. I should be able to get the wheel rotation impulses to the Arduino and then have it trigger a relay to take the photo. I do not think I will have any issues with building the hardware it is pretty straight forward.
Where I am totally stumped is how to write the code to count the number of rotations. Once a certain number of rotations has been reached I want to trigger the camera, then have the Arduino start counting again to take the next photo and continue take photos as long as the wheel is moving.
I would be looking for whole numbers for it to count, for example the wheel has a circumference of about 2M if it rotates 12 times it would let me take a photo every 24M which is good enough for what I am doing. I would just adjust the sketch to get the distance I want between photos.
Although polling is more than fast enough for something happening not more than 20 times a second, I'd probably go for interrupts. Take a look at the reference page for attachInterrupt() (http://arduino.cc/en/Reference/AttachInterrupt), it will answer most of your questions and gives you an example of how to use it.