Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Machine programming a 7segment LED

  1. Sep 10, 2010 #1

    Lately I've been trying to gain an understanding of processors/cpu's and the very lowest possible code you can engineer. I decided I would do a thought experiment where I would distill the computer down to the most basic level I could conceive, and decided that such a computer would be a single 7 segment LED. That seemed sufficiently simple, yet in some ways, still mysterious to me.

    Here's an example of what I mean:


    Imagine this LED hooked up to a keypad with numbers 0-9, each key sending a different signal to the processor. The processor, as I understand it, is best visualized as a network of on/off switches. But this is too general.

    I want to go into more specific details but I'm not sure how. When you press a key on a small 0-9 numbered keypad, what exactly are the interactions occurring to produce the simple 7 bulb display? It's so simple, yet it's still not easy to see.

    I put together another gif of the next step in complexity, primitive animation:


    Attached Files:

  2. jcsd
  3. Sep 10, 2010 #2
    I'm not sure if there is a question in your post, but if you want to pursue the "simplest" computer program to make your gif example in "reality" I would suggest looking into the Microchip PIC chips, perhaps the 16F818. You can find some free C compilers and assemblers...I would start with C, and then look at the assembly code...and go to town.
    I think sparkfun.com may have some kits and stuff that you could use to get going. Microchip has programmers and software but seems to want money in exchange...
  4. Sep 10, 2010 #3
    At the most basic level you don't need any code or even a processor. All you need to do is connect the cathode of each LED to ground and connect the anodes of the LEDs through diodes to the ten switches. For instance the switch for the number one would have two separate connections through resistors and forward biased diodes to the two rightmost vertical LED segments. The keys for all the other numbers could be hard wired through resistors and diodes to the segments they're are supposed to light.

    If you want to use code and a processor then each digit (0..9) is mapped to a character that represents the seven segments (or eight if you count decimal points) and sent to the output port. The LED segments are connected to the output port and are lit when the 7 segment character is output.
  5. Sep 12, 2010 #4
    Hold on a second. When you say each LED, are you talking about each of the 7 bulbs that comprise a single 7 seg LED?
  6. Sep 12, 2010 #5
    Getting used to processors can be intimidating. If your doing this outside of a supporting group, I recommend you start with a project that works. Then, modify it and learn the nomenclature and import of the pieces. There are some books with support code. As I recall, the PIC parts are good about this.

    Best Wishes,

  7. Sep 13, 2010 #6
    Yes, each 7 segment LED comes with a pin for each segment plus a common. I was assuming common cathode but there probably also are common anode 7 segment displays. In that case the cathode of the appropriate segments would be pulled low.
  8. Sep 13, 2010 #7
    Can we explore some extremely basic things based on what you just wrote?

    Terms I am not familiar with:

    pin (an anode?)
    common (a cathode?)

    I also don't know what you mean by "assuming a common cathode" what do you mean?

    All I really know at this point is that electricity flows into the anode and out the cathode. I hardly know much else. Just hoping you could explain things as fundamentally as possible, even if that means helping me get a handle on some of the most rudimentary terms in electronics.

    What would be the difference between a common cathode and common anode display?

    What does it mean to pull the cathode low? no idea what that would mean.
  9. Sep 13, 2010 #8
    Extremely. I don't even want to try to tackle it without getting a grasp on engineering a keypad to light up 10 different combinations of lights (0 - 9). That's boggling enough.

    Can you give me an example of such a project? Let's keep it real simple too, for instance, do you think it's appropriate for me to focus on 7 seg LEDS?

    What do you mean by importing pieces? I'm not sure code is the best place for me to start. I understand a bit of programming (python), but I really want to focus on the most fundamental thing I can think of, and that is a single 7 seg LED fed by a 0 to 9 digit keypad.
  10. Sep 15, 2010 #9
    Whats your backround Loki23?
    You might want to try with some chips that dont have much complicated syntax. I have used Lego mindstorms, paralax robotic kit, and trying now to do some project on PIC. Lego and paralax have some simle and intuitive development software.
  11. Sep 15, 2010 #10


    User Avatar
    Science Advisor

    Loki23, common anode means that all 7 anodes of the 7-segment display are tied (connected) together. Common cathode is the same, except with cathodes connected instead. If you think about it, you only need to control one end of an LED to turn it on or off.

    Pulling something low means connecting (via your microcontroller) that something to ground. Pulling high means connecting it to 5V or whatever your voltage happens to be. Note that most LEDs can't handle 5V directly, and you need a small resistor in-between your input and the LED.
  12. Sep 15, 2010 #11
    ...and pin refers to the wire lead coming out of the 7 segment module.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook