Main:
if UP = 1 then
if STRT = 1 then
gosub Climb
end if
end if
goto Main
end
This worked just perfect with a 12f629. Up must be true before STRT is true. When they are true in that sequence, the program goes to the subroutine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
how do I make a :
if gpio.1 on and if gpio.2 on then set gpio.3 on
statement?
dir PORTB.1 in
dir PORTB.2 in
dir PORTB.3 out
#define PORTB.1 gpio1
#define PORTB.2 gpio2
#define PORTB.3 gpio3
if gpio1 AND gpio2 = 1 THEN set gpio3 on
I think that this is one of the ways to do this, but I am not sure, try it and then tell something. In the meantime I will try to simulate in gpsim.
i believe it should be:
IF gpio1 = 1 AND gpio2 = 1 THEN SET gpio2 ON
you have to give a condition for each part that is being checked in the If statement. Am I correct?
If this isnt working, and it's with pushbuttons, you may need to debounce the switch.
I tried this code and it worked in gpsim. using the "is" instead of the "="
if PORTB.0 is on AND PORTB.1 is on THEN set PORTB.2 on
This one is correct:
IF gpio1 = 1 AND gpio2 = 1 THEN SET gpio2 ON
Not sure why the one with is worked!
Main:
if UP = 1 then
if STRT = 1 then
gosub Climb
end if
end if
goto Main
end
This worked just perfect with a 12f629. Up must be true before STRT is true. When they are true in that sequence, the program goes to the subroutine.