Let's Make Robots!

First Robot Wall Racer

Race fast and Avoiding Obstacle.

 

Your browser is not able to display this multimedia content.


IMG_2646.jpgIMG_2647.jpgI could not figure out how to do the real wall racer yet so I will try this version. I will attemp the real wall racer when I have more free time. Basically is the same as the first robot but I have to modified the code so that the back motor always drive forward and the front motor to turn right and left.

I think I have to play around with the high and low to make the motor turn in the right direction. 

Symbol dangerlevel = 35' how far away should thing be, before we react?

symbol turn = 500 ' this sets how much should be turned

symbol servo_turn = 120 ' 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 1, 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 7 : low 6

low 4: low 5

 

 

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

gosub totalhalt

readadc 1, b1

 

'Look the other way:

gosub rturn ' look to another side

pause servo_turn ' wait for the servo to be finished turning

gosub totalhalt

readadc 1, b2

' Decide which is the better way:

if b1<b2 then

gosub body_lturn

else

gosub body_rturn

end if

return

 

body_lturn:

low 7: high 6

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

 

return

 

body_rturn:

low 7: high 6

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

return

 

rturn:

servo 0, 110' look to one side

return

lturn:

servo 0, 200 ' look to the other side

return

 

totalhalt:

Servo 0,150 ' face forward

pause 50 ' freeze all for one second

return

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Looks good but I dont think the panning is necessary at all unless its just for looks, because the car is going at such a great velocity that the panning wouldnt do anything :D, its better on slower robots (First one)


 

I am making a new one now with two sensor. I am working with the ping sensor so I hope it will works.
Cool!  From the video you just posted it looks like this is coming along nicely.  :D