Programming flaw?

here is my program that is supposed to make my tracked robot move towards light sources over a ceratin brightness. however, when it runs on the PICAXE28x1, it goes forward if it is started in the light, but as soon as the light level drops it turns left and does nothing else. Can anyone find the flaw in my programming?

main:

let pins = 160 'forward

label_33: readadc 3,b3 'read light sensor

if b3< 120 then label_1E 'if light =below level 120 turn and look again

let pins = 160 'forward

goto label_33


label_1E: let pins = 144 'left

wait 2

let pins = 0 'halt

goto label_33

hello, I’m guessing its

hello, I’m guessing its because your in an infinite loop of testing for low light and doing the bottom subroutine.

your bot is still in a low light level even with a left turn

try changing the the bottom goto label_33 to goto main

maybe do a wait 1 after let pins = 160 too just to give it a boost back into the light

I’ve never programmed a PIC before - this is pretty neat to program through proxy :slight_smile:

hope it works!

 


my robots
my garden