Things You'll Need
Instructions
Write the Program
Connect your microcontroller to your computer. Launch the microcontroller's programming software.
Type the code that tells the microcontroller which output channels to use for turning the LEDs on and off. If you are using a display that does not contain a decimal point, set seven of the channels as outputs. If you are using a display that does provide a decimal point, set eight of the channels as outputs. Use contiguous channels to make programming and connecting the display easier.
Create a table on a piece of paper that shows which LEDs to turn on and off to create each number. Draw nine columns and 11 rows with your pencil. Label the leftmost column "Number" and the remaining columns with the names of each of the LED pins. The pins may be named with letters ranging from "A" to "G." Look at your display's documentation to find out the pins' names and locations within the display. Label each row under "Number" with numbers zero through nine.
Write a "1" in each cell of your table to show when an LED is turned on and a "0" for LEDs that are off when creating each number. For example, the number "8" is created by turning every LED on when using a display with a common cathode or off when using a display with a common anode. The cells in the row labeled "8" will each be filled with a "1" or "0," depending on which type of display you have. Check your display's documentation if you do not know which type you have.
Type the code that tells the microcontroller which channels, or LEDs, to send on and off signals to when creating each number. For example, to create the number "8," send an on signal to every output channel. Refer to your table to program each number.
Add a time delay after the code that generates each number to cycle through the numbers automatically. Use a total of 10 delays. If you add a time delay of 1,000 milliseconds, or one second, after each number, a different number will be displayed every second.
Test your code for errors, if your programming application contains that function. Save your code on your computer's hard drive. Upload the code to your microcontroller. Disconnect the microcontroller's power supply.
Connect the LED Display
Place the seven-segment LED display on your breadboard with each pin on a separate copper track.
Connect the necessary pins on the display to the microcontroller's ground terminal using single-core wire. Look at the display's documentation to find out which pins are the ground pins.
Connect a resistor to each of the remaining pins on the display. One end of a resistor lies on the same copper track as one of the pins. The other end of the resistor lies on an empty copper track; that is, a copper track that is not connected to any electronic components.
Connect each of the resistors to an output channel on your microcontroller with single-core wire. Run the wire from the end of the resistor that is not on the same copper track as an LED pin. Use the channels that you designated as output channels in your program.
Connect your microcontroller to a power source. Turn the microcontroller on. The display cycles through numbers zero to nine one at a time.