Loading...
Pages: [1]   Go Down
Author Topic: using a fototransistor to control a servo  (Read 762 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
django
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 96
Posts: 6331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 269
Posts: 25381
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Note the spelling of phototransistor - it has a silent P as in Bath.  smiley-wink
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh in dutch it is spelled with a 'f'
but thanks! it works now smiley-grin
Logged

Pages: [1]   Go Up
Print
 
Jump to: