Shop OBEX P1 Docs P2 Docs Learn Events
Using a Basic Stamp 1 I/O to control the other I/Os as outputs — Parallax Forums

Using a Basic Stamp 1 I/O to control the other I/Os as outputs

profjkarprofjkar Posts: 1
edited 2009-07-06 17:45 in BASIC Stamp
Hi all,

I am having problems making this work. I could use the help if anyone else has seen this before.

I want to use one I/O from a Basic Stamp 1 to sequence the remaining I/O ports as outputs.

For example: If I put an input signal in P0, P1 will go high for .5 seconds and go low. If I put a second hi on P0, P2 will go high for .5 seconds and so on for the rest of the I/Os.

I can make one I/O work, but it stops there.

Please help.

Thanks,

Jim K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-06 16:58
    Attach your program source file to a message. Use the "Post Reply" button and use the attachment manager to upload the file.

    You're proposing a "state machine" where the Stamp program has a different "state" depending on how many times P0 has gone high.
    Look at the Wikipedia article on "state machine" for a description. In this case, each state is a loop to test for P0 going high probably using a PULSIN statement. The "transition" from one state to another pulses P1 or P2 or ... for 1/2 second, probably using a PULSOUT statement.
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2009-07-06 17:14
    It sounds a bit like a Decade Counter like the 4017 IC. Other similar ICs may do the trick also depending on what your input is on P0. Tell us more...
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-07-06 17:38
    Here is one way:
    pulsePin VAR Nib
      FOR pulsePin=1 to 15
      DO : LOOP while in0=0  ' stay here until pin goes high
      HIGH pulsePin     ' pulse 0.5 second as numbered
      PAUSE 500
      LOW pulsePin
      DO : LOOP while in0=1  ' stay here until input goes low
      NEXT
      END
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-06 17:45
    Tracy's suggestion will only work on a BS2. For a BS1, you need to replace the DO:LOOP statements like
    wait0:
       IF PIN0 = 0 THEN wait0
    


    wait1:
       IF PIN0 = 1 THEN wait1
    


    You'd also need to change the FOR loop since there are only 8 I/O pins, not 16.

    You might want to initialize your I/O pins as follows:
    PINS = %00000000
       DIRS = %11111110
    
Sign In or Register to comment.