Assign 6 inputs in one variable
Hi everybody
I can't figure out how to assign 6 ports in one variable.
I've a basic stamp 2 with P3-P4-P5-P6-P7-P8 as inputs.
My idea is to get a event number from this ports, for example if:
P3=1
P4=0
P5=1
P6=1
P7=0
P8=1
event = %101101 = 45
So knowing the value of event, can i work with this code:
rutine1:
IF (event < 1) THEN do_something
event=event - 1
HIGH LED 'just an example
PAUSE 250
LOW LED
GOTO rutine1
do_something:
some code ' here jump when the led has timed on/off "event value" times
Thanks
Deivid
I can't figure out how to assign 6 ports in one variable.
I've a basic stamp 2 with P3-P4-P5-P6-P7-P8 as inputs.
My idea is to get a event number from this ports, for example if:
P3=1
P4=0
P5=1
P6=1
P7=0
P8=1
event = %101101 = 45
So knowing the value of event, can i work with this code:
rutine1:
IF (event < 1) THEN do_something
event=event - 1
HIGH LED 'just an example
PAUSE 250
LOW LED
GOTO rutine1
do_something:
some code ' here jump when the led has timed on/off "event value" times
Thanks
Deivid

Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
·
You could say something like...
·
event = INS
·
...To capture the entire 16-Bit port.· Then you could mask the·pins you are interested in with something like this...
·
event = event & %0000000111111000
·
...At this point you could use the data just as it is, or you can shift it right by 3 to justify the data with something like this...
·
event = event >> 3
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
DIRL = %01000000 A CON 20 porta VAR Word event VAR porta.LOWBYTE Get_Event: compare = %00111111 event = evento & compare IF event = 0 THEN Main Mode_1: event = event - 1 PULSOUT A,3 IF (event > 1) THEN Mode_1 GOSUB Mode_2if event=5 (%00000101), I got 4 pulses in A
should this works?
PS: Right now I haven't a Basic Stamp, this is for a project in classroom.
Thanks
Deivid