I am new to this forum. I was hoping for some help with a project I just started.
I have a SparkFun Electronics - PICAXE-18X Starter Pack. I am using the PICAXE-18X on this board.
I am attempting to make a turret that follows light.
I have 4 LDR’s mounted on a 6”X6” plate in the directions North,South , East and West.
The turret will track the sun.
The problem is that when I debug the LDR outputs I only get three (north,south,east). Is that because the PICAXE-18X can only read 3 inputs.
Is my code wrong any help would be appreciated.
Also I thing my movement code is all wrong but it is a start.
Code is bellow.
I have a SparkFun Electronics - PICAXE-18X Starter Pack. I am using the PICAXE-18X on this board.
I am attempting to make a turret that follows light.
I have 4 LDR’s mounted on a 6”X6” plate in the directions North,South , East and West.
The turret will track the sun.
The problem is that when I debug the LDR outputs I only get three (north,south,east). Is that because the PICAXE-18X can only read 3 inputs.
Is my code wrong any help would be appreciated.
Also I thing my movement code is all wrong but it is a start.
Code is bellow.
Code:
symbol head = 3
symbol neck = 4
symbol NC = 133
symbol HC = 130
b11 = HC
b12 =HC
symbol north = 0
symbol south = 0
pause 100
servo neck,NC
pause 300
servo head,HC 'move servo to centre
pause 300
main:
gosub testnorth
gosub testsouth
'readadc 0,b0 'read channel 0 into variable b0
'readadc 1,b1
'readadc 2,b2
'readadc 3,b3
if b0 < b1 then gosub thnorth
if b1 < b0 then gosub thsouth
debug b0 'transmit value to computer screen
debug b1 ' transmit value to computer screen
debug b2 ' transmit value to computer screen
debug b3 ' transmit value to computer screen
goto main ' jump back to the start
testnorth:
b5=0
b6=0
b7=0
readadc 0,b5 'read channel 0 into variable b0
pause 2
readadc 0,b6 'read channel 0 into variable b0
pause 2
readadc 0,b7 'read channel 0 into variable b0
b0=b5+b6+b7
b0=b0/3
return
testsouth:
b8=0
b9=0
b10=0
readadc 1,b8 'read channel 0 into variable b0
pause 2
readadc 1,b9 'read channel 0 into variable b0
pause 2
readadc 1,b10 'read channel 0 into variable b0
b1=b8+b9+b10
b1=b1/3
return
thnorth:
pause 100
b11=b11+5
servo head,b11 'move servo to centre + 5
pause 100
return
thsouth:
pause 100
b12=b12-5
servo head,b12 'move servo to centre + 5
pause 100
return