Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding a robot with a GP2Y0A02YK sharp infrared range finding sensor [Picaxe Board]
#1
I'm going to be coding a robot that will seek adventure. I've recently gotten into robotics, and this should be a fairly simple task. The GP2Y0A02YK range finder will send off an infrared light and look for it's reflection. It then calculates the time it takes to see a reflection and finds the distance my robot is from an object. I will then use a programming language called Picaxe to control my circuit board so that when it gets within a few feet of an object, it will look left and log the distance from the next object in sight, and then look right and do the same. It will then turn itself and go towards the area where the next object is the farthest away.

I'm going to be using a Picaxe project board, which will allow me to manuever everything with a microproccessor which I can code to with picaxe. I already have a cable for coding with Picaxe from a past project.

Here's a picture of the Picaxe project board which can be bought for $20 online:
[Image: 28510-dscn1098_ps.jpg]

For only $14.50, here's the sensor I'm using:
[Image: R144-GP2Y0A02YK.jpg]

If you want to do your own, here's a Picaxe source. This was originally intended to just turn itself around and randomly move in another direction when in contact with an object, but I modified it do do what I needed.

You're going to need to learn a little picaxe before understanding it. It's not really too similar to any popular languages. I would compare it to visual basic more than anything else (due to it's horrifying [yet popular] syntax).

Picaxe Code:
PHP Code:
Symbol dangerlevel 70
symbol turn 
300
symbol servo_turn 
700 

main
:
readadc 0b1
if b1 dangerlevel then
gosub nodanger 
else 
gosub whichway
end 
if
goto 
main 


nodanger
:
high 5 high 6 low 4 low 7
return


whichway:
gosub totalhalt


gosub lturn 
pause servo_turn
readadc 0
b1
gosub totalhalt



gosub rturn 
pause servo_turn
readadc 0
b2
gosub totalhalt

if b1<b2 then
gosub body_lturn
else
gosub body_rturn
end 
if
return

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

rturn:
server 0,100
return

lturn:
servo 0200 
return

totalhalt:
low 4 low 5 low 6 low 7
Servo 0
,150 
wait 1 
return 
Reply
#2
http://www.rev-ed.co.uk/picaxe/

Some interesting stuff to read about.
Superman I am here to rescue you.
This is Support Forums not Support PMs.  Do not PM me for support unless it's private and site related.
Reply
#3
(02-25-2011, 11:49 PM)Omniscient Wrote: http://www.rev-ed.co.uk/picaxe/

Some interesting stuff to read about.

Indeed. Particularly here: http://www.techsupplies.co.uk/AXE020

And Picaxe Information->Basic Commands.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  hmm im board so i wanted to ask whats your favorite game on the pc lars90 8 924 07-18-2011, 03:22 AM
Last Post: Fragma
  lool Coding mini project Untouch 2 633 04-12-2011, 03:31 PM
Last Post: Untouch
  Need help finding a pdf repair tool Fallenour 3 688 10-30-2010, 09:17 AM
Last Post: Music
  My good friend needs help finding affordable flat + job N3w_2_H@Ck1n™ 8 1,192 01-22-2010, 04:13 AM
Last Post: Extasey
  Mike's Page Bulletin Board mike_mybb_import3284 9 827 07-19-2007, 05:22 AM
Last Post: PoisonDart

Forum Jump:


Users browsing this thread: 1 Guest(s)