For my electronics project we must create a model barrier arm that is activated when a toy car drives up.
We must use a servomotor (hextronik hxt900 9gr) a Picaxe08M microprocessor and a LDR voltage drop.
I have the circuit set up correctly but I am having trouble programming the servo motor. I can get it to go between two postions correctly using the following program. (sorry if not correct, do not remember exactly the program)
Main: servo 2,2
wait 2
servo 2,155
wait 2
goto main
This works but when I use my main program:
Start: servo 2,2
Main: readadc 4,b1
if b1 <150 than Motoron (150 being the value of the LDR when covered)
servo 2,2
pause 100
goto Main
Motoron: servo 2,155
wait 5
goto Main
This does not work an I do not know why, all that happens is that the servo goes to the starting position and stays here but does not move when the LDR is covered.
Please explain why if you know and post a suitable replacement program. (Using picaxe commands)
We must use a servomotor (hextronik hxt900 9gr) a Picaxe08M microprocessor and a LDR voltage drop.
I have the circuit set up correctly but I am having trouble programming the servo motor. I can get it to go between two postions correctly using the following program. (sorry if not correct, do not remember exactly the program)
Main: servo 2,2
wait 2
servo 2,155
wait 2
goto main
This works but when I use my main program:
Start: servo 2,2
Main: readadc 4,b1
if b1 <150 than Motoron (150 being the value of the LDR when covered)
servo 2,2
pause 100
goto Main
Motoron: servo 2,155
wait 5
goto Main
This does not work an I do not know why, all that happens is that the servo goes to the starting position and stays here but does not move when the LDR is covered.
Please explain why if you know and post a suitable replacement program. (Using picaxe commands)