Shop OBEX P1 Docs P2 Docs Learn Events
PBasic question from a newbie — Parallax Forums

PBasic question from a newbie

dholl17207dholl17207 Posts: 5
edited 2007-06-13 18:03 in BASIC Stamp
I am just getting familiar with PBasic and was wondering if there was a way to turn on multiple outputs with one command. For instance when I use HIGH 14 etc. it would be nice be able to say HIGH 14, 15, 11 etc. Is this possible? any help would be appreciated. Thanks.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-13 15:41
    Hello,

    If the direction registers for a group of pins are set to output you can set multiple pins using OUTS (for all 16 pins), OUTL/OUTH (for 8 pins, P0-P7/P8-P15), OUTA/OUTB/OUTC/OUTD (for 4 pins) or OUTx (where x is a pin number, for one pin at a time). Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • dholl17207dholl17207 Posts: 5
    edited 2007-06-13 16:44
    Hi, Thanks for the info. This will help a lot to simplify my progs . If I use OUTL to set pins 0-7 as outputs and have led's connected to these pins, is there a way to set more than one output high on one command line. I have an eight segment display connected to pins 0-7 and would like to be able to turn on various segments at once to create numbers and letters. To do this I enter as follows.
    HIGH 0
    HIGH 2
    HIGH 3
    HIGH 5
    HIGH 6

    Is there a way to simplify this code block to:

    HIGH 0,2,3,5,6 (or something similar) on one line

    Thanks.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-13 17:03
    OUTL does set 8 pins at once…You can either do something:

    OUTL = %10101010

    Or you could use a variable…

    OUTL = ioByte

    …where ioByte is the pattern you want to output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-06-13 17:07
    Typically, I'd do this in "Hexadecimal".

    OUTL = $3C, or
    OUTL = %00110111

    would do what you want.

    Also, you could do:

    OutBits VAR BYTE

    MyVal CON %00110111

    OutBits = MyVal
    OutL = OutBits

    And you could also create an 'alias' to OutL with:

    MyPort VAR OutL

    MyPort = %00110111
  • dholl17207dholl17207 Posts: 5
    edited 2007-06-13 18:03
    Thanks for the help, I'll give these a try.
Sign In or Register to comment.