In a variable, what value to indicate span of pins [16..23] ?
John Kauffman
Posts: 653
I want to put a value into a variable that indicates pins 16..23. I have been unable to phrase this question in a way that gets results from searches in various Spin resources.
Sample:
VAR
long LedsData ' this will get a value that represents pins 16..23
Pub Main
LedsData := ' >>>>> What to put here?? <<<<<
Dira[LedsData]~~
repeat
outa[LedsData] := %10000000 ' desired result: set high pin 16 only
Sample:
VAR
long LedsData ' this will get a value that represents pins 16..23
Pub Main
LedsData := ' >>>>> What to put here?? <<<<<
Dira[LedsData]~~
repeat
outa[LedsData] := %10000000 ' desired result: set high pin 16 only
Comments
Ledsdata := OUTA[16..23]
It does talk about it in the manual. It is under the OUTA entry. The outa register is normally used for outputting data to pins, but it can be read from. This gives a lot more flexibility...hope it helps
Usually what people want is to use named I/O pins, but these are usually constants. You can use CON to declare named constants and use those names in the Pin#..Pin# notation like this:
''Sample
var
byte ledsdata
pub main
DIRA[16..23]~~
DIRA[8..15]~~
OUTA[16..23] := %1000000
ledsdata := OUTA [16..23]
repeat
outa[8..15] := ledsdata
I was hung up on the idea that since there are 32 pins and the are all represented by 'a', I would have to enter a long that had only the 3rd quarter of the long designated; you can see how I got stuck
Mike: right, CON is what most people want, including me. Asking VAR was error on my part.
RK: thanks for demo of actually using a VAR (instead of CON).