Let's Make Robots!

C.D.S.

Navigate via I.R.

Hi this is my first robot based on the Start Here Bot. 

Thank you for all of your help I hope you enjoyed  my first robot.

Here's more pictures:

The brain:

Shiny:

The code (bask in it's glory):

symbol dangerlevelmin = 18 ' how far away should thing be, before we react?

symbol dangerlevelmax = 85 ' how far away should thing be, before we react? note (150 is closer than 110)

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

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

wait 5

'****************************************************************************************************************************************************************

 

main: ' the main loop

servo 0, 150

pause 150

readadc 0, b2 ' read how much distance is straight ahead

gosub checkdangerlevel

 

servo 0, 205

pause 150

readadc 0, b2 ' read how much distance is toward right side

gosub checkdangerlevel

 

servo 0, 150

pause 150

readadc 0, b2 ' read how much distance is straight ahead

gosub checkdangerlevel

 

servo 0, 95

pause 150

readadc 0, b2 ' read how much distance is toward left side

gosub checkdangerlevel

 

goto main ' this ends the loop, the rest are 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 : low 6 : low 4 : high 7

return

 

'****************************************************************************************************************************************************************

whichway:

gosub totalhalt ' first stop!

 

'Look one way:

high 3

gosub lturn ' look to one side

pause 50 ' wait for the servo to be finished turning

readadc 0, b1

low 3

gosub totalhalt

 

'Look the other way:

high 3

gosub rturn ' look to another side

pause 50 ' wait for the servo to be finished turning

readadc 0, b0

low 3

gosub totalhalt

 

' Decide which is the better way:

if b1<b0 and b1 < 18 then

gosub body_lturn

else

gosub body_rturn

end if

return

'******************************************************************************************************************************************************************

 

body_lturn:

high 4:low 5

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

pause 680: gosub totalhalt

return

 

body_rturn:

high 6:low 7

high 5:low 4' turn the robot other way

pause 680: gosub totalhalt

return

'******************************************************************************************************************************************************************

rturn:

servo 0, 225 ' look to one side

pause 200

return

 

lturn:

servo 0, 75 ' look to the other side

pause 200

return

'******************************************************************************************************************************************************************

totalhalt:

high 2

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

Servo 0,150 ' face forward

pause 150' freeze all for 150 milaseconds

low 2

return

 

'******************************************************************************************************************************************************************

checkdangerlevel:

if b2 <= dangerlevelmax and b2 >= dangerlevelmin then

gosub nodanger ' if nothing ahead, drive forward

else 

 

 

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

end if

return

 

 

'*****************************************************************************************************************************************************************

 

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Cool use of CDs for chassis, that's what I did too with my MAEP!

Thank you i am trying to learn ardiuno programing using a teensy and a tamiya track kit good job on your robot

I am around ten and this site really helped me

 

that is sooooo cool im actually working on my first robot

Thanl you! and good luck!

Nice done, and nice touch! Video?

And welcome to the club, thanks for posting :)

 I will post video when th camera starts working again

Uh, and good picture too!!

Thnk you and I will post more pictures when I figure out how to upload them.