Let's Make Robots!

Digital Input Trouble. PART 2!!!!!!!

Ok, sorry to bring you guys another annoying beginner question, but here it is:

My old code was working fine and still is, but there was a minor problem. That minor problem was that if the robot hit a corner at the a small angle the switch would not activate until it was too late. The solution was to add a switch to the other side and connect it to v1 and digital input 6. Note: I am using a picaxe 28x1 with l293d motor driver. Anyways the problem is that the new switch does not seem to be working. Again, I think it is the fault of my code. Here is my code:

main:
high 4 low 5 low 6 high 7
if pin7 = 0 and pin6 = 0 then backwurds
if pin7 = 1 and pin6 = 1 then main
if pin7 = 1 then main
if pin7 = 0 then backwurds
if pin6 = 1 then main
if pin6 = 0 then backwurds
backwurds:
low 4 high 5 high 6 low 7 pause 2000
low 4 high 5 low 6 high 7 pause 1700
goto main

Any ideas?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ok, Thanks again!
you could use anything, but the right pins are a bit thicker than a resistor lead so you might get intermittent problems if the pin is loose. I would get the right pins, but till then you could use anything.

That worked code worked beautifully! I now have the two switches working. Thanks Ant!

by the way, If I want to put on a servo do I have to get a special servo pin or can I just solder in a lead from led or a resistor?

the program wil never get to "if pin6 = 1 then main" because either of the two lines above it will direct the program eslewhere. See what happens if you gdo this(notice the commented lines, and goto main):

main:
high 4 low 5 low 6 high 7
if pin7 = 0 and pin6 = 0 then backwurds
if pin7 = 1 and pin6 = 1 then main
'if pin7 = 1 then main
if pin7 = 0 then backwurds
'if pin6 = 1 then main
if pin6 = 0 then backwurds

goto main
backwurds:
low 4 high 5 high 6 low 7 pause 2000
low 4 high 5 low 6 high 7 pause 1700

goto main