Shop OBEX P1 Docs P2 Docs Learn Events
Write output pins as byte — Parallax Forums

Write output pins as byte

RevaveRevave Posts: 2
edited 2011-03-01 08:43 in BASIC Stamp
Hello,

I am new with the basic stamp. I have a question about writing outputs.
I would like to copy a variable with datatype byte to output pins 8 -15. (BS2pe)

For example:

Value VAR Byte

If Value is dec 3, pin 8 and 9 should be high.
If Value is dec 10, pin 9 and 11 should be high.
This up to 255 (8 output pins needed)

Is there a simple command available to copy the VAR to OUTH (pin 8 to 15)?
I've tried the next command, but it doesn't work.
OUTH = Value

Best regards,
Reijnko

Comments

  • HumanoidoHumanoido Posts: 5,770
    edited 2011-02-28 03:31
    Hi Revave, you can see a program similar to this technique here.
    http://forums.parallax.com/showthread.php?129932-Penguin-Robot-Math-Punctuation-%28REVB%29

    Try this example:
    value = %11000110
  • RevaveRevave Posts: 2
    edited 2011-02-28 03:36
    Thank you!

    I've found a solution:

    Value=128
    DIRS=%1111111100000000
    OUTH Value
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-02-28 05:57
    Revave, glad that worked for you. Decimal values work good. For ease of programming, use of binary can develop a 1 to 1 correspondence between the value bits and the pins, visually. What project are you working on?
  • ercoerco Posts: 20,256
    edited 2011-02-28 17:23
    INL and INH are also very useful commands to familiarize yourself with. Ain't no quicker way to read 8 input pins!
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-02-28 21:19
    Remember, INL and INH are just the byte names.
    The word name is INS.
    The nibble names are INA, INB, INC, IND
    and the bit names are IN0 - IN7 and IN8 - IN15.
  • bsnutbsnut Posts: 521
    edited 2011-03-01 01:51
    To expand Humanoido point, you can address bits in a byte like this.

    value VAR Byte
    value.BIT1 = 0

    Remember, this way can only be done BS2 and above
  • ercoerco Posts: 20,256
    edited 2011-03-01 08:43
    Remember?

    At my age and level of sleep deprivation ???
Sign In or Register to comment.