i have just received my gp2d12 ir sensor
and i don’t know how to hook it up to the mini atom bot board
onto the analog I/O’s
for the basic atom
thank’s
but now the sensor isn’t responding
when i put my hand in front of it
is there a programming error?
'variable definitions
mid var word
left var word
right var word
right_detect var word
left_detect var word
middle_detect var word
left = -1000
mid = 1500
right = 1000
low p0
sound 9,[100\880, 100\988,100\1046,100\1175]
pause 1000 'wait one second
main:
gosub a2d_check 'get the IR information
left_detect = left_detect/10
right_detect = right_detect/10
middle_detect = middle_detect/10
left=(left - 5) min 1325
right=(right - 5) min 1325
mid =(mid - 5) min 1425
left = (left + left_detect) max 1725
right = (right + right_detect) max 1725
mid = (mid + middle_detect) max 1525
if mid <15 then skip
left = (left - middle_detect) max 1325
right = (right - middle_detect) max 1325
skip:
servo 0,left 'turn sensor left
servo 0,mid 'turn sensor right
servo 0,right 'return to middle position
pause 20
a2d_check:
adin ax2,0,AD_RON, right_detect
adin ax2,0,AD_RON,middle_detect
adin ax2,0,AD_RON,left_detect
return
goto main
Look at one of chunga’s threads on the IR sensor. He bought one a few weeks ago and posted some code he used I believe.
I’ve also written good code to handle the Sharp IR sensors as well as the IRPD.
8-Dale
where?
Go to my website and look for Rovers–>W.A.L.T.E.R.–>Software and download the latest version (bottom of the page).
8-Dale
is it for the gp2d12?
and if so, is it only for one?
Read the comments in the program. All the your questions are answered there. I have comments on nearly every line of code or each major section and subroutine.
8-Dale
this page url is invald
is it somewere else?
Which page?
Huh, dunno…
oh well, im really having trouble finding working code for my GP2D12 thats all.
This program will make a sound that raises in pitch the closer you hold your hand to the sensor. The IR sensor would be plugged into the AX0 pin on the Bot Board.
irvariable var word
loopit:
adin 0, irvariable
sound 9,[10\(ir * 10)
goto loopit
when i compiled it it said theres and error on line 3?
i checked the spelling and its all correct.
(gosh i’m so unlucky today…lol)
Jim, in the sound line, ir needs to be irvariable…
like
but it still has an error on the (adin 0, irvariable)
[/quote]
Whoops I have been using the Pro so the syntax is a little different, set aside the typos…
irvariable var word
loopit:
adin ax0,1,ad_ron,irvariable
sound 9,[10\(irvariable*10)]
goto loopit
This works I tested it.