Shop OBEX P1 Docs P2 Docs Learn Events
Setting Multiple Pin States — Parallax Forums

Setting Multiple Pin States

David KissickDavid Kissick Posts: 15
edited 2005-09-26 21:14 in BASIC Stamp
Hey group!

This should be an easy question. I need to be able to set several pins on a BS2 from Low to High at the same time. Is there code that will do this or do I have to change them individually? for the curious, this is to control transistors driving LEDs in order to create a light show. Thanks for the help.

David

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-09-26 05:15
    David -

    Specific groups of pins can be addressed as one entity, as follows. See the PBASIC Stamp Manual or the PBASIC Editor Help File for more information.

    OUTS = All 16 outputs, pins 0-15

    OUTL = Pins 0-7·· OUTH = Pins 8-15

    OUTA = Pins 0-3·· OUTB = Pins 4-7·· OUTC = Pins 8-11·· OUTD = Pins 12-15

    INS, INH, INL, INA, INB, INC, IND operate in the same manner for inputs.

    Regards,

    Bruce Bates
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-26 12:45
    Just to follow-up on Bruce's response, when using an OUT register you'll want to use the associated DIR register as well so that you can make the pins outputs. If, for example, you wanted PO-P7 outputs, with P0-P2 high, you could do it like this:

    OUTL = %00000111
    DIRL = %11111111

    Of course, you only need to set DIRL once, and your program can use those pins as outputs as required. If you download our StampWorks book you see that we have a little lightshow project included -- it might give you some ideas for your project.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • David KissickDavid Kissick Posts: 15
    edited 2005-09-26 21:14
    Thanks Guys!

    That's exactly what I needed.

    David
Sign In or Register to comment.