PDA

View Full Version : Binary Counter



dmyhand
06-08-2005, 04:12 AM
I want to build a device which will count in binary using 8 LEDs. I teach networking and I am finding that most, if not all, of my students understand things better with a visual representation. Would this be easy to do with a BASIC Stamp? I am new to circuit design, but willing to learn. Thanks, Dennis Myhand

Jon Williams
06-08-2005, 04:22 AM
Easy?· You betcha.· Simply connect LEDs to P0 - P7 (through a 470 ohm resistor) and run the following code (just one way to do it).

' {$STAMP BS2}
' {$PBASIC 2.5}

LEDs··········· VAR···· OUTL··········· ' on P0 - P7
counter········ VAR···· Byte

Reset:
· DIRL = %11111111······················' make P0 - P7 outputs·

Main:
· FOR counter = 0 TO 255
··· LEDs = counter
··· PAUSE 250
· NEXT
· GOTO Main


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Post Edited (Jon Williams (Parallax)) : 6/7/2005 8:29:48 PM GMT

dmyhand
06-08-2005, 05:06 AM
Too Flippin' Kewl!...Thanks. Now I can buy a kit.

Jon Williams
06-08-2005, 05:14 AM
That's as easy as popping into your local RadioShack and picking up one of our "What's A Microcontroller?" kits. It includes an excellent introductory text by Andy Lindsay.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Gadgetman
06-08-2005, 06:31 PM
One small question...

How many mA does each LED draw?

And how many LEDs can be lit at one time before you run into problems?

The FAQ suggests not having more than 3 LEDs powered at any time to avoid flaky and unpredictable behaviour...
http://www.parallax.com/dl/docs/prod/stamps/basicstampfaq.pdf
(See page 10)
This FAQ may need to be updated about the latest models, though...
(Latest revision is from 2000...)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...

dmyhand
06-08-2005, 08:47 PM
Good point, Gadgetman. I will pick up the kit on Friday and begin looking into that. I want to make sure that this will be able to handle what I am doing. Of course, I may need to buy a bigger module, or a bigger power supply, or both!

Jon Williams
06-08-2005, 11:47 PM
If you're nervous about current consumption, get low current LEDs (2 mA each) and use 1K resistors.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

dmyhand
06-11-2005, 09:12 AM
I want to thank everyone for the great assistance given this week. I picked up the kit this afternoon and about an hour and a half later, my counter was ticking away. You guys are tremendous. Thanks, again, Dennis Myhand

Ryan Clarke
06-11-2005, 09:33 AM
If you are designing a 'clock' instead of a binary counter consider-

For one type of design you'll need 7 LEDs for seconds, 7 LEDs for min., and 6 LEDs for Hours as so:

Hours- from left to right: one row of two, one row of four
Min - from left to right: one row of three, one row of four
Sec - from left to right : one row of three, one row of four

Then you only have to convert each 'place'-

You can also teach binary counting on fingers, just be careful when you get to four! I used to tell kids that we count in base 10 because we have ten fingers and toes- but if we were born with only thumbs then we'd count in binary... and that the characters in Springfield (the Simpsons) must count in octal (they have 8 fingers!)

Ryan

dmyhand
06-11-2005, 08:32 PM
I've tried teaching them using fingers for the last two years (Since I started teaching) and it simply is not "Visual" enough for this bunch. Not even the idea of making four seem like something the school administration would object to has had any help. It is almost like, if it isn't electronic, it isn't worth looking at. I am also working on a little VB program which will do the same thing.

Ryan Clarke
06-12-2005, 12:55 PM
Have you seen the T-shirt that ThinkGeek sells that shows a hand counting in binary? :) Or the "you are dumb" written in binary (ASCII code) shirt? Maybe those would help? Just a thought...

Ryan