james
- 31st July 2007, 20:17
Hello,
Am in my first month of learning to program, and have completed most projects in the " PicBasic Projects - Book, by : Dogan Ibrahim ".
I am currently trying to control a servo motor(Tower Hobbies: STD TS-53) via a toggle switch. Switch one way to turn the servo Clockwise, opposite position for Counter Clockwise. Center position to center the servo
when power is applied my servo spins to the center and then vibrates and will not respond to switch. I am new and looking to learn, if I am using code improperly please inform me, I dont want to start off on the wrong foot.
using pic16F648, my code is as follows :
Code:
'PICBasic pro manual servo control program
symbol switchCW = porta.1
symbol switchCCW = porta.0
symbol servo = portb.0
Position var byte
start:
'look at switches on Port A
IF switchCW = 1 and switchCCW = 1 then goto loop
Position = 150
Pulsout servo, Position
pause 18
loop:
if SwitchCW = 0 then
Position = 130
Pulsout servo, Position
Pause 18
endif
If SwitchCCW = 0 then
Position = 170
pulsout servo, Position
Pause 18
endif
Pause 18
Goto loop
*****************
end of program....
Thank you, for any feedback
Am in my first month of learning to program, and have completed most projects in the " PicBasic Projects - Book, by : Dogan Ibrahim ".
I am currently trying to control a servo motor(Tower Hobbies: STD TS-53) via a toggle switch. Switch one way to turn the servo Clockwise, opposite position for Counter Clockwise. Center position to center the servo
when power is applied my servo spins to the center and then vibrates and will not respond to switch. I am new and looking to learn, if I am using code improperly please inform me, I dont want to start off on the wrong foot.
using pic16F648, my code is as follows :
Code:
'PICBasic pro manual servo control program
symbol switchCW = porta.1
symbol switchCCW = porta.0
symbol servo = portb.0
Position var byte
start:
'look at switches on Port A
IF switchCW = 1 and switchCCW = 1 then goto loop
Position = 150
Pulsout servo, Position
pause 18
loop:
if SwitchCW = 0 then
Position = 130
Pulsout servo, Position
Pause 18
endif
If SwitchCCW = 0 then
Position = 170
pulsout servo, Position
Pause 18
endif
Pause 18
Goto loop
*****************
end of program....
Thank you, for any feedback