How I did it…
The IR sensor and IR LED are done exactly per the picaxe manual’s instructions, period. To get the sensor to respond “directionally” I simply put it at the end of a small tube and crimped down the other end leaving just a small hole. The inside is painted black. Like this:
That's it.
I have the IR led's on the transmitter (beacon) sending out a constant command (the equivalant of holding down a button on a remote) and the servo scans and sees if the sensor can see the IR beam at each location. With the set-up I have now, it can find/miss the beacon withing 5 servo steps. I.e. if I have the servo go in 5-step steps, it will jump over the beam a lot... In 2-step steps it will find it every time.
Here's the code I am using:
pause 1000
gosub clearscreen
gosub mainscreen
servo 1,225
pause 500
buttonmain:
if pin1=1 then
gosub clearscreen
setfreq m8
serout 0,T9600_8,(254, 128) 'Sets line 1 position 1
serout 0,T9600_8,("Starting Sweep ")
serout 0,T9600_8,(254, 192) 'Sets line 2 position 1
serout 0,T9600_8,("IR Beacon ")
setfreq m4
servo 1,225
pause 500
gosub roomone
endif
goto buttonmain
mainscreen:
setfreq m8
serout 0,T9600_8,(254, 128) 'Sets line 1 position 1
serout 0,T9600_8,("Button 1 ")
serout 0,T9600_8,(254, 192) 'Sets line 2 position 1
serout 0,T9600_8,("To Start Sweep ")
setfreq m4
return
clearscreen:
setfreq m8
serout 0,T9600_8,(254, $01)
pause 10
serout 0,T9600_8,(254, $01)
pause 10
setfreq m4
return
roomone:
let b2=200
gosub servomove
let b2=180
gosub servomove
let b2=145
gosub servomove
let b2=120
gosub servomove
let b2=90
gosub servomove
let b2=68
gosub servomove
let b2=35
gosub servomove
goto buttonmain
servomove:
servo 1,b2
pause 500
gosub ircheck
return
ircheck:
IRIN [100,ircheck2],4,b1
if b1=11 then foundit
ircheck2:
return
foundit:
gosub clearscreen
setfreq m8
serout 0,T9600_8,(254, 128) 'Sets line 1 position 1
serout 0,T9600_8,("Beacon Heading")
serout 0,T9600_8,(254, 192) 'Sets line 2 position 1
serout 0,T9600_8,(#b2," O'clock")
setfreq m4
pause 5000
gosub clearscreen
gosub mainscreen
goto buttonmain