Go Down

Topic: using a fototransistor to control a servo (Read 1 time) previous topic - next topic


I succeeded in controlling a servo motor using the example code of the software.
Now i bought myself a fototransistor and i would like to use it to control the servo with the arduino chip (UNO) (for example a lot of light means go to 45 degrees/no light go to 0).
Does anyone know how to use the output of the fototransistor so i can use this to give the servomotor an input of 0-180?

thx in advance!


Connect the phototransistor between pin A0 and +5V.  Connect a resistor between A0 and Ground.  Use analogRead(A0) to get values.  Figure out the range of values you get.  In loop(): Read a value, map the value to the range 0 to 180 using the map() function, and move the servo to that position.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


Note the spelling of phototransistor - it has a silent P as in Bath.  ;)


oh in dutch it is spelled with a 'f'
but thanks! it works now :D

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131