EveryReasonTo
New Member
I'm trying to design a simple program that will vary the speed of a continous rotation servo dependant on how bright the sun is but I'm struggling to 'calibrate' the LDR to get a linear reading.
This is the main code I've come up with so far:
This works but as you would expect, anything over a tiny bit of daylight and the servo is going full speed.
How can I get it so that I get a more linear change of speed?
Thanks!
This is the main code I've come up with so far:
Code:
Init: Servo 1,150 'Stop servo
Main: readadc 4,b1 'Read LDR, store value in b1
b2 = b1/4+150 'The servo only needs to spin in noe direction, so this makes b2 always >150
debug 'Show values of b1,b2 on screen
goto SMov
SMov: Servopos 1,b2 'Move servo
goto main
How can I get it so that I get a more linear change of speed?
Thanks!