The photomotion is a general method for a very low-cost, easy-to-build motion detector. It uses a simple photoresistor as a sensor and is triggered by quick variations in the light value.
This detector has a range of about 3-4 meters. It is relatively robust and will work well in dimm light. However, it doesn't work at all in total darkness (could maybe be fixed using an infrared LED) and is too sensitive in broad daylight (could maybe be fixed by automatically adjusting the threshold).
We used a 50kOhm photoresistor and a 50kOhm resistor (to bring the resistor's output between 0 and 5V). The main part of the program detects variations between two readings of the photoresistor:
// ... int motion(long time = 100) {
- define PHOTO_IN 0 // Photoresistor input.
int before = analogRead(PHOTO_IN); delay(time); return (analogRead(PHOTO_IN) - before);}
The original idea was retroengineered from cheap motion detectors found in a Flea market (see this post).
Note: You can use another value for the photoresistor, however it is important that the resistor's resistance approximately matches that of the photoresistor.
| Fichier attaché | Taille |
|---|---|
| photoresistor_schema.jpg | 8.94 Ko |
| photomotion_attiny.c | 3.48 Ko |
| photomotion.pde | 1.53 Ko |
Commentaires
Question
What is that IC chip in the center?
Thanks Yuri
ATtiny
It's an ATtiny. However the above code will only work with Arduino (ATMega8/168/..) but the method is the same.