Shop OBEX P1 Docs P2 Docs Learn Events
help with using an array or list order queues (beginner) — Parallax Forums

help with using an array or list order queues (beginner)

CelestialDemonCelestialDemon Posts: 20
edited 2013-05-02 20:28 in BASIC Stamp
ok so i think i got the set up correctly for the variables and whatnot and it should record them and put them in a queue of some sorts, but my question is how do i use this queue to do what i want in the order that the inputs were pressed? (they are levers being pressed and are held down and released one by one and i want the program to remember the order so that after the first lever is released the second one that was pressed will take do its thing.) like say the levers were pushed a second apart from each other and corresponding lights light up with each lever but only one light at a time until the first lever is released then the light attached to the second lever in line should light up, then the second lever is released and then the third light and lever act etc.. what lines of command do i need now to make this happen?

list VAR Nib(4)

pressedA VAR Byte
pressedB VAR Byte
pressedC VAR Byte
pressedD VAR Byte
index VAR Byte


INPUT 5
INPUT 6
INPUT 7
INPUT 8
OUTPUT 0
OUTPUT 1
OUTPUT 2
OUTPUT 3
START:
LOW 0
LOW 1
LOW 2
LOW 3
IF IN8 = 0 THEN intersectionA
IF IN7 = 0 THEN intersectionB
IF IN6 = 0 THEN intersectionC
IF IN5 = 0 THEN intersectionD




intersectionA:
IF pressedA = 1 THEN start
list(index)= 1
index = index + 1
pressedA = 1
GOTO start


intersectionB:
IF pressedB = 1 THEN start
list(index) = 2
index = index + 1
pressedB = 2
GOTO start




intersectionC:
IF pressedC = 1 THEN start
list(index) = 3
index = index + 1
pressedC = 3
GOTO start




intersectionD:
IF pressedD = 1 THEN start
list(index) = 4
index = index + 1
pressedD = 4
GOTO start
Sign In or Register to comment.