BS1 with servo
Archiver
Posts: 46,084
I have a bs1 and I want to control a servo with it. I cannot find
any code to do it, is it possable ? boath directions ?
any help for a newbe is very welcome - chris
any code to do it, is it possable ? boath directions ?
any help for a newbe is very welcome - chris
Comments
position on Futaba servos.
Loop:
PULSOUT 0,150
PAUSE 20
GOTO Loop
> I have a bs1 and I want to control a servo with it. I cannot find
> any code to do it, is it possable ? boath directions ?
> any help for a newbe is very welcome - chris
get you started.
Larry
'********************************************************************
' OMSI BOT 02-16-2000
' This code is for a Mini Sumo Robot. It uses a cds sensor to
' to detect a white line, then it spins around. If an object
' is detected with the iodx (IR Object Detector) the motor on
' the opposite side rotate faster to turn toward the object.
' Remember to find the deadzone or neutral of the servos.
' this example code the dead zone is set to 150.
'
' How I/O pins are used:
'
' pin 0 = Piezo - output - Makes Sounds
' pin 1 = LED1 - output - LED1 on or off
' pin 2 = LED2 - output - LED2 on or off
' pin 3 = Servo Right - output - 150 dead zone
' pin 4 = Servo Left - output - 150 dead zone
' pin 5 = IODR - input - IR Object Detector Right
' pin 6 = IODL - input - IR Object Detector Left
' pin 7 = CDS - input - Reads value of light
'
' Servo Right SR pin 3 : Forward = -20 Deadzone = 150 Reverse = +20
' Servo Left SL pin 3 : Forward = -20 Deadzone = 150 Reverse = +20
'
'********************************************************************
Variables:
Symbol thres = b0 ' Threshold for light level
Symbol srvr = b3 ' Servo Right
Symbol srvl = b4 ' Servo Left
Symbol cds = b7 ' Hold current light level
Symbol led1 = pin1 ' LED 1
Symbol led2 = pin2 ' LED 2
Symbol iodr = pin5 ' Infrared Object Detector Right
Symbol iodl = pin6 ' Infrared Object Detector Left
Symbol dvr = 150 ' Deadzone for Right Servo
Symbol dvl = 150 ' Deadzone for Left Servo
'********************************************************************
Initialize:
dirs = %00011111 ' Sets i/o pin directions
' Play a short tune
sound 0,(60,15,75,15,90,15,60,30,60,15,75,15,90,15,60,30)
pause 4000 ' Wait about 4 seconds
pot 7,128,cds ' Get Dark Threshold
thres = cds / 2
Main:
pot 7,128,cds ' Read cds for White Line
if cds
[noparse][[/noparse]Non-text portions of this message have been removed]