Your use of AND is unusual.
IF PORTB.7 = 1 THEN
PORTB.6 = 1 AND POT0 = 25
ELSE
PORTB.6 = 0 AND POT0 = 0
ENDIF
I would use
IF PORTB.7 = 1 THEN
PORTB.6 = 1
POT0 = 25
ELSE
PORTB.6 = 0
POT0 = 0
ENDIF
Your use of AND is unusual.
IF PORTB.7 = 1 THEN
PORTB.6 = 1 AND POT0 = 25
ELSE
PORTB.6 = 0 AND POT0 = 0
ENDIF
I would use
IF PORTB.7 = 1 THEN
PORTB.6 = 1
POT0 = 25
ELSE
PORTB.6 = 0
POT0 = 0
ENDIF
Steve Earl www.datageo.co.uk
That creates a problem because if the pin drops lows after its exited the routine, the LED and POT0 value do not change.
I suppose if I add an IF THEN check in the main program loop to see if the pin is low and turn off the led and send 0 to the POT, that should fix that issue.
Not a problem because
IF PORTB.7 = 1 THEN 'If portb.7 is 1
PORTB.6 = 1 'set portb.6 to 1
POT0 = 25 'set poto to 25
ELSE 'If portb.7 is any value but 1
PORTB.6 = 0 ' set portb.6 to 0
POT0 = 0 'set poto to 0
ENDIF
how do you interpret this bit of code?
Steve Earl www.datageo.co.uk
Jump into the subrountine, run that code once, jump out, if the pin turns low, the led stays on because the IF THEN code isnt being run. Therefore there has to be IF THEN code in the main program loop to detect if PORTB.7 = 0 and turn off the LED and send 0 to the POT.
Very interesting. In your main code you have an IF statement to detect PORTB.7 =1 and another IF statement to detect PORTB.7=0.
or you could just call the subroutine from the main program as it does both checks.
Steve Earl www.datageo.co.uk
Bookmarks