Shop OBEX P1 Docs P2 Docs Learn Events
Need Help with simple programming (beginner) — Parallax Forums

Need Help with simple programming (beginner)

CelestialDemonCelestialDemon Posts: 20
edited 2013-05-07 18:13 in BASIC Stamp
ok, I will make this simple and straightforward. I am new to programming and its hard to find exact information on how to do exactly what i want to do. My project is a 4-way stop sign stop where, using mini photocells, program 4 lights that are attached to the stop signs (1 for each stop sign) that detect when a car is stopped at the sign and if multiple cars approach the intersection simultaneously, which one gets to go first. This has to be like a real life situation, where once a car leaves, its light will go off and the person who's 2nd in line to go, their light will go on etc. Im not sure how to loop all of these together in the program or how to make it "remember" which sensor was detected 2nd and so on.

This is all i had so far to start, which made 1 light go on when the sensor was covered and the light would go off when the sensor was uncovered. (using basic stamp editor 2.5.3 and stamp bs2 and version 2.5)

input 1
output 2
RUN:
if in1 = 0 then RUN
high 2

OFF:
if in1 = 1 then OFF
low 2

goto RUN

or something along those lines..i cant remember for sure, but any help on this matter would be greatly appreciated.. i dont know all the commands and stuff so I know there is something someone out their knows that will help. thank you!
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-24 06:47
    First of all, you'll need to learn "the commands and stuff". There's no way around it. The "BASIC Stamp Syntax and Reference Manual" and the "What's a Microcontroller?" tutorial are the mainstays of learning how to use the Stamps. Make sure you have copies and become familiar with them.

    This is a school project, so we really can't do it for you, but we can give you advice and answer specific questions.

    Programs like this usually end up being what's called a "finite-state machine" (do a Google search for this) where you have several loops and each represents what's called a state. The program sits in a state until something happens, then it goes to one of several other states or stays in the same state depending on what happened. When it goes to another state, the program may make something happen (like turn LEDs on or off). The state represents the memory. In the example you posted, you've got two states, RUN and OFF.

    In your case, this is a bit more complicated since you might have cars waiting in turn for something to happen and you may want to remember the order in which they arrived. You can do this with a finite-state machine with 16 states (4 potential cars, each with 4 possible arrival positions) or more depending on how you control the lights. There are other ways where you can simplify the number of states needed, like having a 4 element array with numbers 0-4 in each element with 0 meaning no car and 1-4 indicating a car and the number giving the priority.

    Are you using a BS1 or BS2 Stamp? If it's a BS2, you can use DO / LOOP and a different form of IF (IF THEN / ELSE / ENDIF)
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2013-04-24 07:03
    Depending on where you are ... "After a full-stop has been made, vehicles usually have the right-of-way to proceed through the intersection in the order that they arrived at the intersection. In the USA, if vehicles arrive at approximately the same time, each driver must yield to the drivers on their right, while in South Africa drivers must use common sense and make eye contact and gestures."

    But as Mike suggests, a state machine is your best bet to finding a solution.

    Reference:
    http://en.wikipedia.org/wiki/All-way_stop
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-24 09:59
    This sounds like a metering light. One car gets to proceed each time the light turns green, and the light immediately turns red again. Is that right? Those are common at congested freeway or bridge approaches. Your description with the stop signs and lights threw me off, because I was imagining an octagonal hexagonal red stop sign with a green light attached to it, huh??--Where have I ever seen anything like that? But now I'm thinking a bicolor LED or a pair of LEDs that can be either red or green.

    Oh, Welcome to the forums!
  • ercoerco Posts: 20,257
    edited 2013-04-24 13:51
    That's a fun problem! For starters, your program must continuously run (no pauses) checking all photocells, and storing the order of cars' arrivals, probably in 4 variables (or one if you're tricky). Based on which car arrived first and/or has the right of way (yield to car on right, etc), you decide which sign gets its LED turned on . Meanwhile you keep scaning all the photocells and updating car positions. Once you verify (via photocell) that the chosen car has left, then turn off that LED and update your variables to decide which is the next LED to turn on. Never stop your photocell scanning loop, just use IF/THEN and HIGH/LOW statements when needed. One big happy loop.

    Man, how I wish I had juicy problems like that back in school. Me, I had to use flashlight bulbs, batteries and colored cellophane to make an "electric map" of the population of the Scandinavian countries. No doubt inspired by the famous Gettysburg Electric Map, an all-too familiar field trip to gradeschool kids in northern Virginia. Whatever happened to that? http://www.savetheelectricmap.com
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-04-24 14:17
    wow, thank you guys, didnt expect so many responses over night. And to the first post, I understand and wish i had more time to read the whole manual and learn the programming and language better, however since its a project i have a very limited time to finish and haven't taken a programming course before, but apparently my teacher thinks im "smart" and suggested i try something like this. And yes its basically a 4 way stop with stop signs and one could think of each sign having a light on it that will turn on when its that person's time to go. I will look up the things you told me to and hopefully it helps, i have only 2 weeks. I would very much like to learn all of this, im just constrained with time.

    I just wish someone could give me an example statement that looped two photocells together (in1 and in2) with led lights (output 3 and output 4) so that a light would light up if a car reaches the intersection but the other wouldn't unless the first car is gone and the second is still there (so as to not cause an accident) and from there I could figure out how to loop 4 of them. I learn well by examples, and its hard to find good ones like this.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2013-04-24 15:04
    erco, What? No relays?


    CelestialDemon,
    Here is an example of a state machine in pseudo code to your Two input Two output request:
    ST1:
           If IN1 = HIGH then
              OUT3 = HIGH
              GOTO ST2
           If IN2 = HIGH then
              OUT4 = HIGH
              GOTO ST3
    -------------------------------------
    ST2:
           If IN1 = HIGH then GOTO ST2
           OUT3 = LOW
           GOTO ST1 
    -------------------------------------
    ST3:
           If IN2 = HIGH then GOTO ST3
           OUT4 = LOW
           GOTO ST1 
    
    
  • ercoerco Posts: 20,257
    edited 2013-04-24 20:54
    apparently my teacher thinks im "smart"

    Bummer, dude. Maybe you better set him straight, one way or the other. :)
  • bsjohnbsjohn Posts: 19
    edited 2013-04-25 06:21
    This sounds like a great project and exercise. You will learn a lot about the Basic Stamp and microcontroller programing when you get through this.

    Here's a good tutorial on the basic stamp http://www.parallax.com/Portals/0/Downloads/docs/article/SIUApplicationMicros.pdf

    Really pay attention to the section on flowcharting which will help you map out program. Once you have the flowchart, go find the appropriate pbasic commands to do what you want. I try to do this on all of my projects, it saves a lot head scratching and rewriting.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-25 10:50
    In organizing your thoughts about this, there are a couple of very different ways to implement a state machine such as this nice project is.

    One is by way of modes, where you will have interlinking program loops, each of which handles one possible state of the system and has conditions for entry and exit. For example, the short program Beau posted has three modal loops with simple conditions for remaining in the loop and for exiting the loop. This can get quite complicated as you add different possible states and conditions, and the code ends up with a lot of IFs and GOTOs. You can draw something like that out with a bunch of circles and arrows connecting them. It can work if the system is symmetrical and simple, but it comes to resemble a plate of spaghetti if there are a lot of special cases.

    Another approach is to use state variables instead of modes. In that approach there is one main mode where the program execution spend most of its time, and it takes short side trips to act on changes in the state variables. Here is a little example:
    [FONT=courier new][SIZE=1]cars VAR NIB   ' a bit is 0 if car not present, 1 if present, 4 bits represent the state of all locations
    cars0 VAR NIB   ' the previous state, helper to detect changes of state
    changes VAR NIB  ' a 1 bit means there has been a change of state in the cars variable.
    main:
      DO   ' most of the time in this loop
         cars = INA  ' the detectors are on p0 - p3
         changes = cars ^ cars0    ' this uses the XOR logic operator to detect changes
         IF changes THEN GOSUB actions
         cars = cars0   ' update previous state.
      LOOP
    
    actions:   ' short side trips
        IF changes & cars THEN  ' a bit has gone from 0 to 1
           DEBUG CR, "car has arrived at ", DEC NCD changes
        ENDIF
        IF changes & cars0 THEN  ' a [SIZE=1]bit has gone from 1 to 0[/SIZE]
           DEBUG CR, "car has left from ", DEC NCD changes
        ENDIF
        RETURN[/SIZE][/FONT]
    

    Think of the arrival of cars as a queue, and you have to line up who gets to go next. In a state variable formulation, that would be an array of numbers with a head and a tail, and arrivals put a number on the queue at the head and departures take a number off at the tail. You also have to account for the possibility that two cars arrive at the same time.
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-04-26 03:41
    OK, I understand a bit about state machines now, and im working on getting a two part state machine to work, the problem im having is that whatever if/then statement i have first in the line, thats the only statement that the code reads and the only statement that takes affect.. for example this is my makeshift code for two levers connected to two separate led's where i push a lever and one light goes on, i release it and light goes off, but the second led wont react when i push the second lever, or i should say whichever statement i put 2nd doesn't work. and i need to always define my if/then statements i cant leave them like "IF IN6 = 1 THEN HIGH3" it doesnt work like that.. aslo im using PBASIC 2.5 and stamp BS2

    INPUT 5
    INPUT 6
    OUTPUT 2
    OUTPUT 3


    start:
    IF IN6 = 1 THEN ST2 ;;;; since this statement is first my LED attatched to pin 3 will turn on perfectly when i push the lever
    HIGH 3
    GOTO ST2


    IF IN5 = 1 THEN ST1
    HIGH 2
    GOTO ST1


    ST1:
    IF IN5 = 1 THEN ST1
    HIGH 2
    basic:
    IF IN5 = 0 THEN basic
    LOW 2


    GOTO start


    ST2:
    IF IN6 = 1 THEN ST2
    HIGH 3
    yea:
    IF IN6 = 0 THEN yea
    LOW 3


    GOTO start
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2013-04-26 06:12
    Your missing a "Goto Start" just before the "ST1:" label
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-04-26 17:03
    ok, well i did that but the same thing still is happening.. the first statement light will go on but the second one will not.. if i switch the top two statements around then the other one goes on but the same thing happens and the second one will not..
  • TinkersALotTinkersALot Posts: 535
    edited 2013-04-26 17:19
    Another approach to consider here: Try to divide the problem up. Meaning: get only one thing to work the way you want, and add to it.

    and --->>> THIS IS MPORTANT
    MAKE BACKUP COPIES

    of your program file as you work on it (give yourself a naming scheme like ver1, ver2, ver3 etc.) as you go forward.

    Few things are as disappointing as getting something working, then changing it making it all break and having no way to get back to where you were.
  • TinkersALotTinkersALot Posts: 535
    edited 2013-04-26 17:27
    ...but the second led wont react when i push the second lever, or i should say whichever statement i put 2nd doesn't work.

    wondering if you are "infinite loop" ... must play computer... in6=1 is true, so I go to ST2, where as long as in6 is still one I will stay there forever but when in6 is false then I will spin around on yea yea yea (which is a great beatles refrain but likely not what you want)....hmmmm....
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-04-26 18:42
    yah i was thinking something like this too.. i hate it because without the knowledge of how exactly the programming works for this its hard to determine when and where infinite loops will occur and so i cant create a state machine to do a simple task like this..
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-26 20:21
    If you look at the Wikipedia article on state machines, you'll see that they use state diagrams, kind of like a flowchart for a state machine. It's very straightforward to translate a state diagram to a program since each state is essentially a loop in the program and the various conditional transitions to other states are done with IF statements.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-27 00:07
    OK, (snip...) for example this is my makeshift code for two levers connected to two separate led's where i push a lever and one light goes on, i release it and light goes off, but the second led wont react when i push the second lever

    On the face of it, the action you describe just here can be done with a very simple loop:
    OUTPUT 2
    OUTPUT 3
    DO
      OUT3 = ~ IN6
      OUT2 = ~IN5
    LOOP
    

    Low state of buttons is transferred directly to high state of leds. The squiggle symbol ~ is an operator that means NOT, so input 0 input becomes output 1, and vice versa. In this program, both lights can be on at once when both buttons are pressed.

    When you revisit your program in post #11, think it through like a computer. The program starts, finds the button at in6 up, jumps to ST2, waits there until the button is down, then turns on the led, waits at yea until the button is up, then goes back to start where it jumps right back to ST2. It never gets to ST1.

    Here is a quick example in which the start loop tests both buttons until one or the other is pressed. Unlike the program above, only one light can be on at a time.
    start:
      LOW 2
      LOW 3
      IF IN6 = 0 THEN ST2
      IF IN5 = 0 THEN ST1
      GOTO start
    
    st1:
      HIGH 2
      IF IN5=0 THEN st1   
      GOTO start
    
    st2:
      HIGH 3
      IF IN6=0 THEN st2
      GOTO start
    
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-04-28 00:32
    wow thanks tracy, thats works well, and yah i see where the loop was coming from now, and so yah ill just have to make this into 4 lights and then i have to figure out a way so that if 4 are pressed at once (or relatively at the same time like 1 second or so between them) that once the first one that was pressed is released the program will automatically turn on the light in the second one that was pressed and so on. This may already do this actually i will try it. thanks a lot youve been a big help
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-28 10:53
    I'm glad that helped and you have your thinking cap on. I know that even though I've been doing this a long time, the first step is the hardest. Although, I should add, most challenging projects seem to be a whole series of first steps, -- get used to it! -- but very satisfying when completed.
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-04-30 12:56
    I hear that.. so yah this works fine, the only problem is since cars are going to be coming at random the order of the program reads will work for the first car to reach the stop but then if more than two cars stop at a time, like say 3 or 4 then after the first one who got there leaves, regardless of the order they arrived the program will only read from top to bottom 8,7,6,5 inputs and do the program in that order, not in the order that the cars arrived.. if there is an easy way to manipulate the program to hold the order of the cars in which they arrived?

    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 ST3
    IF IN7 = 0 THEN ST2
    IF IN6 = 0 THEN ST1
    IF IN5 = 0 THEN ST0
    GOTO start

    st0:
    HIGH 0
    PAUSE 3000
    IF IN5=0 THEN st0
    GOTO start

    st1:
    HIGH 1
    PAUSE 3000
    IF IN6=0 THEN st1
    GOTO start
    st2:
    HIGH 2
    PAUSE 3000
    IF IN7 = 0 THEN st2
    GOTO start
    st3:
    HIGH 3
    PAUSE 3000
    IF IN7 = 0 THEN st3
    GOTO start
  • SapphireSapphire Posts: 496
    edited 2013-04-30 18:00
    You have come a long way since your first post with your program, and it looks good. But double check the st3: routine. I think IN7 should be IN8 in the IF statement...

    To answer your question, there are ways to keep track of the order of arrival, such as a queue or list. But they will require significant modification to your program to implement. For example, right now in the start routine, you jump to the state based on the first input that is zero. To preserve the order, you would have to scan each input, and if it is zero, save it in a queue or list (which is really just a variable array). Then after all the inputs have been scanned, you would then have to go through the queue by going to each state in the order it was placed in the queue. Once that car leaves, you take it off the queue, go back and see if any more cars arrived, adding them to the end of queue, and then take the next one from the head of the queue. Study up on variables first because you will need at least 4 of them to do this, probably more.
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-04-30 19:37
    ok, would that drastically change my programming? because i really only have like a few days before its presented.. ill read up on them but so far what iv read only confuses me since theres not a specific area that tells me how to specifically fix my problem in the manuel lol
  • SapphireSapphire Posts: 496
    edited 2013-04-30 21:11
    Not drastically, but substantially. What you have is good, and it works (did you fix the IN7 to IN8 in st3?).

    What you need to keep the arrival order isn't in the manual. It's a programming concept called a list or queue. You would have to understand that first abstractly, then translate it into code, and then put it in your program. That's a tall order for only a few days if this is your first programming exercise. It is not a trivial task.

    If you choose to do it, here are some hints that may help:

    1. You will need at least 4 variables for the arrival queue (or list, I use the terms interchangeably)
    2. You will need to know how to set these variables to unique values representing each approach with an occupied sensor
    3. You will need to know how to read these variables from the top to the bottom of the queue
    4. You will need to determine which state to go to next based on the the value at the top of the queue
    5. You will need to remove the top item from the queue after the car leaves the approach and move the others up
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-05-02 19:15
    ok so here it is.. i need to create an array basiclly that holds the 4 places and goes in order from which one was first and second.. i got the making variables part down i think, and the actions needed to hold the places, i just now need the commands to set the thing in motion, i will post it up, if anyone can quickly take it and arrange it so itll work out id be happy.. :)

    list VAR Byte(3)
    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
    ' 'IF IN8 = 0 THEN st0 '' these are my initial starting lines, i dont think i need them anymore but ill keep them for now
    ' 'IF IN7 = 0 THEN st1
    ' 'IF IN6 = 0 THEN st2
    ' 'IF IN5 = 0 THEN st3
    GOTO start
    st0:
    HIGH 0
    PAUSE 3000
    IF IN5=0 THEN st0
    GOTO start
    st1:
    HIGH 1
    PAUSE 3000
    IF IN6=0 THEN st1 '''basically in these sections is where i need to implement my array in a way so that it plays the order out correctly, im just confused as to what to put, i know i need things like "IF in6 = some variable in queue or idk.."
    GOTO start
    st2:
    HIGH 2
    PAUSE 3000
    IF IN7 = 0 THEN st2
    GOTO start
    st3:
    HIGH 3
    PAUSE 3000
    IF IN7 = 0 THEN st3
    GOTO start


    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
  • SapphireSapphire Posts: 496
    edited 2013-05-02 20:29
    Very good. You have the list built. A few thing to fix.

    1. The declaration list VAR Byte(3) should be list VAR Byte(4) since there are 4 inputs. Although the index goes from 0 to 3, the array has to be defined as 4 bytes.
    2. The place where you will decide which state to go to is right before the first GOTO start, just after the IF IN5=0 THEN intersectionD. You need to do it there, and not in the state itself.
    3. To figure out which state to go to, just look at the first element in the array, list(0). You can do this with a BRANCH statement like this:
    BRANCH list(0), [start,st1,st2,st3,st4]
    

    BRANCH is like GOTO but based on the value of list(0). Note that if the value is zero, the the program will go back to start. Otherwise it will go to one of the four states.

    4. Lastly, you will have to do a few things when you exit each of the four states. You have to clear the pressedX variable (X=A to D) since that state has now been served. And you have to shift the list because the top item list(0) is now done and decrement the index (so it doesn't point past the end of the list).
    pressedA=0  ' clear the flag
    list(0)=list(1)  ' shift the list
    list(1)=list(2)
    list(2)=list(3)
    list(3)=0  ' clear the last entry
    index = index-1 ' decrement the index  
    

    All but the fist instruction above are the same for all states, so ideally they should go into their own routine. I'll let you think about how to do that.

    As you put this all together, I suggest you add a few DEBUG statements to show the index, the list and where the program is going until you have it working right.
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-05-03 03:24
    thanks.. im trying to put everything u said into my code, its hard since im basically new, but where do i put the code:

    pressedA=0 ' clear the flag
    list(0)=list(1) ' shift the list
    list(1)=list(2)
    list(2)=list(3)
    list(3)=0 ' clear the last entry
    index = index-1 ' decrement the index

    i know i need 4 of them for each pressedA through pressedD but was confused when u said that this code needs to go into or at the end of each of my four states, which im guessing are st0 - st3? or.. idk and also do i need need lines or not anymore?

    'IF IN8 = 0 THEN st0 i guessing i dont need them because i have a list that determines where my program goes
    ' 'IF IN7 = 0 THEN st1
    ' 'IF IN6 = 0 THEN st2
    ' 'IF IN5 = 0 THEN st3
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-05-03 12:22
    this is what it looks like.. i have till tuesday in reality to get this done.. but i need to know if i will beable to make it work by then otherwise i have to go with a simpler means and that would pretty much make the project a piece of Smile lol.. so if this can get done and working and whoever is able to help me with this id even be willing to pay then a small amount through paypal ... this is how it looks after the help from you sapphire

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}




    list VAR Byte(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
    BRANCH list(0), [start,st0,st1,st2,st3]
    GOTO start


    st0:
    HIGH 0
    PAUSE 3000
    IF IN8=0 THEN st0
    pressedA=0 ' clear the flag
    list(0)=list(1) ' shift the list
    list(1)=list(2)
    list(2)=list(3)
    list(3)=0 ' clear the last entry
    index = index-1 ' decrement the index
    GOTO start


    st1:
    HIGH 1
    PAUSE 3000
    IF IN7=0 THEN st1
    pressedB=0
    list(0)=list(1)
    list(1)=list(2)
    list(2)=list(3)
    list(3)=0
    index = index-1
    GOTO start


    st2:
    HIGH 2
    PAUSE 3000
    IF IN6 = 0 THEN st2
    pressedC=0
    list(0)=list(1)
    list(1)=list(2)
    list(2)=list(3)
    list(3)=0
    index = index-1
    GOTO start

    st3:
    HIGH 3
    PAUSE 3000
    IF IN5 = 0 THEN st3
    pressedD=0
    list(0)=list(1)
    list(1)=list(2)
    list(2)=list(3)
    list(3)=0
    index = index-1
    GOTO start


    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
  • SapphireSapphire Posts: 496
    edited 2013-05-03 13:05
    I think that should work. Try downloading it to your Stamp and watch it run.
  • CelestialDemonCelestialDemon Posts: 20
    edited 2013-05-03 13:21
    i have tried it. and i push the levers down one by one and nothing happens, sometimes one light will go on but in the end it doesnt
  • SapphireSapphire Posts: 496
    edited 2013-05-03 14:47
    Do you have pull-up resistors on the inputs? Can you post a schematic?
Sign In or Register to comment.