I/O pin selection(RE-ASSIGNMENT)
![hmlittle59](https://forums.parallax.com/uploads/userpics/199/nCR6ABWFQF1HY.jpg)
Hello All,
First let me see if I can ask this were it make since. If I have (3) I/O pins assigned to (sw1,sw2,sw3) High/Low and want to RE-ASSIGN them so I only have one(1) FOR/NEXT loop, were (sw4) is either one of the other (sw1 or sw2 or sw3) pin values, will that assign pin# still be kept and can I ck that status(HIGH/LOW) in the FOR/NEXT loop?
1) sw1 Pin 1(I/O)
2) sw2 Pin 2(I/O)
3) sw3 Pin 3(I/O)
RE-ASSIGN to:
4) sw4 = sw1...or...sw4 = sw2...or...sw4 = sw3...(Can a I/O pin variable be RE-ASSIGNED to another variable and still work the same?)
will (sw4) now be ASSIGN the new I/O pin?
For I = 1 to 255
IF (sw4 = 1 ) then EXIT
NEXT I
thanks for any help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
First let me see if I can ask this were it make since. If I have (3) I/O pins assigned to (sw1,sw2,sw3) High/Low and want to RE-ASSIGN them so I only have one(1) FOR/NEXT loop, were (sw4) is either one of the other (sw1 or sw2 or sw3) pin values, will that assign pin# still be kept and can I ck that status(HIGH/LOW) in the FOR/NEXT loop?
1) sw1 Pin 1(I/O)
2) sw2 Pin 2(I/O)
3) sw3 Pin 3(I/O)
RE-ASSIGN to:
4) sw4 = sw1...or...sw4 = sw2...or...sw4 = sw3...(Can a I/O pin variable be RE-ASSIGNED to another variable and still work the same?)
will (sw4) now be ASSIGN the new I/O pin?
For I = 1 to 255
IF (sw4 = 1 ) then EXIT
NEXT I
thanks for any help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
Comments
for i = 4 to 6
if ins.bit(i) = 1 then exit
next i
The direction bits and output pins are handled similarly. Again, read the manual in the section on memory.
I did explain it clear enough. Let me re-word it after I go and read the memory section first though. It's more about variable re-assignment then pin location
thanks Mike
Howard
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
That's the word I was looking for...now I'm stuck again. I'll have to find some other way to skin this cat.
thanks again
maybe I'll learn to use CASE statements
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
In that case, aliases are what you need to use. You also have to be creative in how you use variables. Make sure you're using the smallest units that work (bits, nibs, bytes, words). Sometimes making a table of variables with the names of the routines where they're used will help you identify when they're not needed. Sometimes recoding some routines will free up a little bit of storage. If you have a small loop you may be able to eliminate a FOR loop by repeating the code using constants instead of an index variable.
I've been using all variables over and over again....no variable is SAFE!!! I have about 4 that I can't mess with though and some are saved into DS1302 RAM and Reloaded/Refreshed before returning to the Main Menu. I've only done some programming with (bits,nibs) in 6502 Assembly code way back when...So that will be a re-training if I go that route. I set some flags to let me know were I'm coming from in the Code now and I thought it through last night and it may work if I try it but it looked MESSY in my HEAD but I don't know how it will work once I get it Coded. I do still need to read about Alias though.
thanks Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam