hello
can anyone check my proramming
i am doing the same project.....
solar tracker
pic 16f877
2cds with dc motor
Code:
v1 var byte 'variable v1
v2 var byte 'variable v2
v3 var byte 'variable v3
TRISA = 1 'Set all PORTA pins as inputs
TRISc = 0 'Set all PORTc pins as outputs
start:
pot porta.0,255,v1 'Read 1st CdS Sensor (east)
pot porta.1,255,v2 'Read 2nd CdS Sensor (west)
if v1 <= 230 then skp 'start program
if v2 > 230 then slp 'is it dark enough to sleep? (sleep mode)
skp:
if v1 = v2 then start 'If equal, do nothing
if v1 > v2 then greater 'If greater, check how much greater
if v1 < v2 then lesser 'If lesser, check how much lesser
greater: 'Greater routine
v3 = v1 - v2 'Find the difference
if v3 > 10 then cw 'Is it within range? If not, go to cw
goto start 'In range do again
lesser: 'Lesser routine
v3 = v2 - v1 'Find the difference
if v3 > 10 then ccw 'Is it within range? If not, go to ccw
goto start 'Do again
slp:
low portc.0 'stopping the solar tracker for moving
low portc.1 'stopping the solar tracker for moving
goto start
cw: 'Turn the sensor array clockwise
high portc.o 'Turn on h-bridge
pause 100 'Let it turn for a moment
goto start 'Check again
ccw: 'Turn the sensor array counter clockwise
high portc.1 'Turn on h-bridge
pause 100 'Let it turn a moment
goto start 'Check again
end
Bookmarks