73Views4Replies

Author Options:

Using a photo sensing servo. Answered

Hey guys I am trying to get a servomotor which is attatched to a photo sensor to read a light source.  I have servo attached to analog pin 1 and using analogRead to read the value, but I want the maximum value it reads.  Any ideas

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
dsm5286
dsm5286

7 years ago

yes arduino. The servo motor w/ a photo sensor on it. It will read two different lights and record the angle the light reading is the highest for one on its first sweep (0-180). Then on its return sweep (180-0) read the value of the light an at it's highest value record the angle.
It then subtracts the two angles and spits out a yardage onto the lcd screen which correlates to the angles. I got the servo to sweep back an forth. Got the lcd to print. just having trouble getting the code right for the sensor to read the light.

0
caitlinsdad
caitlinsdad

Reply 7 years ago

Ah, it is a photo sensor mounted on the arm of the servo, not in circuit with the servo. Look up the tutorials for photo sensor on arduino.cc or adafruit.com. I believe the analog to digital conversion gives it a fixed range of values to interpret. You can then calibrate it to correspond to your servo position.

0
dsm5286
dsm5286

Reply 7 years ago

Yes sorry I might not have worded very well. Thank you.

0
caitlinsdad
caitlinsdad

7 years ago

1. Is this an arduino you are using?
2. Why is the photo sensor connected to the motor?
3. Are you trying to read the motor or the photosensor?
4. What are you trying to with your setup? Make the motor run when light is detected?