Start Here robot goes nowhere

I built the robot and so bassically all it does is

1. Spins around untill something comes close to it (does that alot.)

2. Rolls backward a few inches

3. Rolls forward for a few inches

 

 

So do I have to make a program myself to tell it not to be so Autistic or what. Its nothing like in the video of the Start here robot.

Yes I checked the wiring.

Yes I checked the wiring. And the code I am using is this:

 

 

 

Symbol dangerlevel = 70 ’ how far away should thing be, before we react?

symbol turn = 300 ’ this sets how much should be turned

symbol servo_turn = 700 ’ This sets for how long time we should wait for the servo to turn (depending on it´s speed) before we measure distance

 

main: ’ the main loop

readadc 0, b1 ’ read how much distance ahead

if b1 < dangerlevel then

gosub nodanger ’ if nothing ahead, drive forward

else 

gosub whichway ’ if obstacle ahead then decide which way is better

end if

goto main ’ this ends the loop, the rest are only sub-routines

 

 

nodanger:’ this should be your combination to make the robot drive forward, these you most likely need to adjust to fit the way you have wired your robots motors

high 5 : high 6 : low 4 : low 7

return

 

 

whichway:

gosub totalhalt ’ first stop!

 

'Look one way:

gosub lturn ’ look to one side

pause servo_turn ’ wait for the servo to be finished turning

readadc 0, b1

gosub totalhalt

 

 

'Look the other way:

gosub rturn ’ look to another side

pause servo_turn ’ wait for the servo to be finished turning

readadc 0, b2

gosub totalhalt

 

’ Decide which is the better way:

if b1<b2 then

gosub body_lturn

else

gosub body_rturn

end if

return

 

body_lturn:

high 6 : low 5 : low 7 : high 4 ’ this should be your combination that turns the robot one way

pause turn : gosub totalhalt

return

 

body_rturn:

high 5 : low 6 : low 4 : high 7 ’ this should be your combination that turns the robot the other way

pause turn : gosub totalhalt

return

 

rturn:

servo 0, 100 ’ look to one side

return

 

lturn:

servo 0, 200 ’ look to the other side

return

 

totalhalt:

low 4 : low 5 : low 6 : low 7 ’ low on all 4 halts the robot!

Servo 0,150 ’ face forward

wait 1 ’ freeze all for one second

return

 

 

It sounds like you need to

It sounds like you need to either change the the code for the motor pins in the program or move your motor wiring around to make the code work. I would say change the code to make it work. It looks like you plugged in the code straight from the example but the chances are you motors aren’t wired up exactly as Frits had his. How to determine the proper motor pin states per the walkthrough:
 
 
Enter this code into your editor, and press F5 while the robot is connected:

high 4
low 5


One of the wheels should turn in one direction. Does your wheels turn forward? If so, this is the instruction for that wheel to turn forward.

If the wheel is turning backwards, you can try this:


low 4
high 5

To turn the other wheel, you need to enter

high 6
low 7

(or the other way around for opposite direction.)
 
 
 
You need to take the combinations that work for you and change the underlined parts of the code:
nodanger:’ this should be your combination to make the robot drive forward, these you most likely need to adjust to fit the way you have wired your robots motors
high 5 : high 6 : low 4 : low 7
return
 
as well as this part:
 
body_lturn:
high 6 : low 5 : low 7 : high 4 
pause turn : gosub totalhalt
return
 
body_rturn:
high 5 : low 6 : low 4 : high 7 
pause turn : gosub totalhalt
return
 
 
Sorry about the line breaks, the text editor just hates me.
Let us know the results.

Wow, thanks it works alot

Wow, thanks it works alot better. 

 

But to make sure I got everything right here is the codes:

 

Right forward: High 4,Low 5

Left forward: High 6,Low 7

 

 

Body Rturn: high 4:low 5:high 6:Low 7

 

Body Lturn: Low 5:High 6:Low 7:high 6

 

Does this seem right?

 

But either way it runs much more smoothly now, it no longer goes around in circles and navigates through my house well. Also I have AA batterys in there non rechargeble (four of them) so I will be replacing it with AA rechargebles so it runs smoother.

 

 

Thanks everybody for your help, I hope to someday be able to help out others. 

 

Once again, thanks.

Good to hear

Hmm… error in the post perhaps? If the correct setup for the motors both going forward is:

Right forward: High 4,Low 5

Left forward: High 6,Low 7

you can wrap that up as:

high 4:low 5: high 6: low 7

The colons are equivalent to starting a new statement so it’s the same as expressing everything one line at a time.

The bodyRturn subroutine would be:

low 4: high 5: high 6: low 7

bodyLturn would be:

high 4: low 5: low 6: high 7

Your posted Rturn would be the same as going straight ahead and the posted Lturn part is missing pin 4’s state.

Alright that seems to do it,

Alright that seems to do it, Gizbot (what I named it.) runs much more smoothly now and can navigate through a maze (sorta).

 

Thanks.