Shop OBEX P1 Docs P2 Docs Learn Events
How to display the the binary value of a variable on LEDs? — Parallax Forums

How to display the the binary value of a variable on LEDs?

Jeena99Jeena99 Posts: 14
edited 2009-11-24 16:42 in BASIC Stamp
I want 4 LEDs to display the value of a variable in binary.
Those LEDs are connected to P0 ,P1,P4,P5
Any Help Is appreciated.........Jeena

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-24 15:18
    Look at page 90 of the BASIC Stamp Syntax and Reference Manual for one way to access the individual bits of a variable. If you don't have it, you can download the Manual by going to Parallax's main webpage and clicking on the "Downloads" tab, then on the "BASIC Stamp Documentation" link. I assume you know how to use a Stamp to light an LED. If not, look at Chapter 2 of "What's a Microcontroller?" which you can download from the "Stamps in Class Downloads" link off the "Downloads" page.
  • stamptrolstamptrol Posts: 1,731
    edited 2009-11-24 15:18
    Jeena,

    It will be much easier if you can re-arrange things so your leds are on p0,p1,p2,p3 so that you can use the OUTA command. The command is made to do exactly what you're asking about.
    If you must use the the pins you've noted, it can be done by using OUTA and OUTB with some masking and/or shifting of bits.

    Have a look at the Editor's Help file under OUT.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • ercoerco Posts: 20,256
    edited 2009-11-24 16:42
    Depending on your Stamp, it can be as simple as

    PINS=B0

    or

    OUTL=B0

    for 8 bits.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
Sign In or Register to comment.