Menu

if and if comand

Help
2008-09-03
2013-05-30
  • Nobody/Anonymous

    how do I make a :
    if gpio.1 on and if gpio.2 on then set gpio.3 on
    statement?

     
    • Ricardo Lameiro

      Ricardo Lameiro - 2008-09-03

      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.

       
    • Nobody/Anonymous

      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.

       
    • Ricardo Lameiro

      Ricardo Lameiro - 2008-09-06

      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

       
    • Hugh Considine

      Hugh Considine - 2008-09-13

      This one is correct:
      IF gpio1 = 1 AND gpio2 = 1 THEN SET gpio2 ON

      Not sure why the one with is worked!

       
    • Nobody/Anonymous

      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.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.