Shop OBEX P1 Docs P2 Docs Learn Events
Binary Counter — Parallax Forums

Binary Counter

dmyhanddmyhand Posts: 5
edited 2005-06-12 04:55 in BASIC Stamp
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

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-07 20:22
    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
    400 x 562 - 5K
  • dmyhanddmyhand Posts: 5
    edited 2005-06-07 21:06
    Too Flippin' Kewl!...Thanks. Now I can buy a kit.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-07 21:14
    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
  • GadgetmanGadgetman Posts: 2,436
    edited 2005-06-08 10:31
    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...
  • dmyhanddmyhand Posts: 5
    edited 2005-06-08 12:47
    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 WilliamsJon Williams Posts: 6,491
    edited 2005-06-08 15:47
    If you're nervous about current consumption, get low current LEDs (2 mA each) and use 1K resistors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • dmyhanddmyhand Posts: 5
    edited 2005-06-11 01:12
    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 ClarkeRyan Clarke Posts: 738
    edited 2005-06-11 01:33
    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
  • dmyhanddmyhand Posts: 5
    edited 2005-06-11 12:32
    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 ClarkeRyan Clarke Posts: 738
    edited 2005-06-12 04:55
    Have you seen the T-shirt that ThinkGeek sells that shows a hand counting in binary? [noparse]:)[/noparse] Or the "you are dumb" written in binary (ASCII code) shirt? Maybe those would help? Just a thought...

    Ryan
Sign In or Register to comment.