PDA

View Full Version : How to display the the binary value of a variable on LEDs?



Jeena99
11-24-2009, 09:40 PM
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

Mike Green
11-24-2009, 11:18 PM
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.

stamptrol
11-24-2009, 11:18 PM
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

erco
11-25-2009, 12:42 AM
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."