Shop OBEX P1 Docs P2 Docs Learn Events
4 bits out in one line of code? — Parallax Forums

4 bits out in one line of code?

al cookeal cooke Posts: 8
edited 2006-08-24 16:57 in BASIC Stamp
I'd appreciate help with this code problem including listing constants and variables. I'm trying to use a 4 to 16 decoder to supply enables to data latches (9) and save pins. Thanks for any help. Al

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-24 03:13
    Al -

    All four sets of contiguous output pins can be addressed as follows:

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

    Regards,

    Bruce Bates
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-08-24 12:57
    Note, if you use OUTA

    OUTA = $0F ' Set all OUTA pins high
    OUTA = $00 ' set all OUTA pins low

    You first have to set DIRA properly.

    DIRA = $0F ' Set the OUTA pins to all OUTPUT.

    So:
    DIRA = $0F ' Set pins to output
    MAIN:
    OUTA = $0F ' Set pins high
    PAUSE 200 ' Wait a bit
    OUTA = $00 ' Set pins low
    PAUSE 200 ' wait a bit
    GOTO MAIN
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-24 15:50
    If you're trying to add I/O lines and save pins it would seem shift registers are the better way to go.· Adding 32 outputs requires only 3 I/O pins from the BASIC Stamp.· Adding 32 Inputs on top of that requires only one more I/O line.· That's 64 I/O pins from 4!· I hope this helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • al cookeal cooke Posts: 8
    edited 2006-08-24 16:57
    Thankyou Bruce and Allan for the full example. Ive read the manual but didn't get it. Now I do.
    Thankyou Chris. I am using 74HC373s for 72 outputs not all of which are in use at the same time plus two dual digital pots for PWM. This complicates the wiring but simplifies the programing I think. Al
Sign In or Register to comment.