PDA

View Full Version : Is this a valid statement?



dbachman
- 22nd January 2009, 01:41
for digit = 0 to 6
lookup digit,(4,5,9,10,6,2,3), portb

I know you can put the number in a var but can you "stick" on portb this way?

Thanks, Don

elec_mech
- 22nd January 2009, 13:02
dbachman,

I haven't played with lookup in a while, but according to the manual, no. I assume you're trying to set the pins on portb high and low according to the value of digit. I haven't tested this, but try something like:



for digit = 0 to 6
lookup digit, (4, 5, 9, 10, 6, 2, 3), portb_out
portb = portb_out
next digit


I'm not sure if you need the for loop or not, depending on what you're trying to do. If this doesn't work, let me know and we can get a little more 'creative'.

-Tony

sayzer
- 22nd January 2009, 16:04
for digit = 0 to 6
lookup digit,(4,5,9,10,6,2,3), portb

I know you can put the number in a var but can you "stick" on portb this way?

Thanks, Don

Yes, it will work (TRISB = 0)
Also,

READ (Temp DIG X),PORTB
Or
POT Pin,255,PORTB
or
ADCIN 0, PORTB


they all work.

elec_mech
- 22nd January 2009, 20:25
Okay, I feel like a dolt, but at least I learned something today. Thanks Sayzer. :D

dbachman
- 23rd January 2009, 01:44
Thanks guys, I haven't tried it yet but I will here in the very near future.

Don

n0yox
- 8th February 2017, 05:33
Can anyone tell me why this does not work:

if var8 = 1 then goto beper : J = 3

The if statement works but J does not = 3 ?

HenrikOlsson
- 8th February 2017, 07:53
The J=3 statement isn't executed when VAR8=1 because you're telling to jump to beper.

If you want to set J=3 when the IF statement is true then

IF var8 = 1 then
J=3
Goto beper
ENDIF
or simply move J=3 to after the beper label in your program.

/Henrik.

Dave
- 8th February 2017, 12:47
You are exiting the code and jumping to a label "beper". The statement j=3 is never getting executed the way you have written it. If "beper was a subroutine (ie GOSUB beper) then it would be returned to after executing and, set j=3 as the next statement.

n0yox
- 9th February 2017, 18:34
Thank you, that fixes my problem.