I understand how to program add a bumper into the list of objects, just not how to make the robot carry out a left turn when it hits something these are my two attempts
1.------------------------------------------------------------- (It is not done yet) 'this is an expiremental program that uses a singel bumper to make the 'robot turn left when it hits something, i hope it works
Dim Front AS New oDio1
Dim S1 As New oServo Dim S2 As New oServo Dim CenterPos As New oByte Dim x as New oWord Dim y as New oWord
'------------------------- Sub Main() CenterPos = 31 Call Setup Do Call GoRight y = 100 Call Delay
Call GoForward y = 100 Call Delay
Call GoReverse y = 100 Call Delay Loop End Sub '----------------------- Sub Setup() Front.Direction = cvInput Front.IOLine = 6
S1.Ioline = 3 S1.Operate = cvTrue S1.Center = CenterPos
S2.Center = CenterPos S2.Operate = cvTrue S2.Ioline = 12 S2.InvertOut = cvTrue
End Sub
Sub turnleft_Code() S1 = 53 S2 = 0 y = 100 Call Delay End Sub
Sub Delay() For x = 1 To y:Next x End Sub
Sub GoForward() S1 = 0 S2 = 0 End Sub
Sub GoReverse() S1 = 53 S2 = 53 End Sub
Sub GoRight() S1 = 53 S2 = 0 End Sub
2.------------------------------------------------------------------------(not shure how this is supposed to work, but the manual told me to do this and it didn't work)
'this is an expiremental program that uses a singel bumper to make the 'robot turn left when it hits something, i hope it works
Dim turnleft As New oEvent Dim frontbumper As New oDio1 Dim WIRE As New oGate Dim oofb As New oDio1
Dim S1 As New oServo Dim S2 As New oServo Dim CenterPos As New oByte Dim x as New oWord Dim y as New oWord
'------------------------- Sub Main() CenterPos = 31 Call Setup Do Call GoRight y = 100 Call Delay
Call GoForward y = 100 Call Delay
Call GoReverse y = 100 Call Delay Loop End Sub '----------------------- Sub Setup() frontbumper.Ioline = 6 frontbumper.direction = cvInput WIRE.Input1.Link(frontbumper) WIRE.Output.Link(turnleft.Operate)
oofb.Ioline = 20 oofb.direction = cvOutput oofb.Value = 1
S1.Ioline = 3 S1.Operate = cvTrue S1.Center = CenterPos
S2.Center = CenterPos S2.Operate = cvTrue S2.Ioline = 12 S2.InvertOut = cvTrue
End Sub
Sub turnleft_Code() S1 = 53 S2 = 0 y = 100 Call Delay End Sub
Sub Delay() For x = 1 To y:Next x End Sub
Sub GoForward() S1 = 0 S2 = 0 End Sub
Sub GoReverse() S1 = 53 S2 = 53 End Sub
Sub GoRight() S1 = 53 S2 = 0 End Sub