Iguana Labs will be closing its doors for good around August 11th.
We will keep lowering our prices until our inventory is gone.
Click here for the latest price list and availability.
Iguana Labs                   800-297-1633
Back To Previous PageProductsView Cart ContentsCheckout

Microcontroller
Beginner
Kit
$149.00


Sign  Up For
Newsletter

Feedback

Shipping
Information
 

 

Digital Clock

We can use a 2051 microcontroller to build a clock using 7 segment displays. This is tricky since we need to seperately control 28 LEDs and have 2 input switches and we only have 15 I/O lines.

Start by building the circuit as shown in the 7 segment display tutorial (click here) except you can leave off the 5 volt connection to pin 3 of the 7 segment display. Then repeat this 3 times for the next three 7 segment displays. As you can see in the picture you can just run jumper wires from one display to the next. 

At this point you can test your connections by connecting each display pin 3 to 12 volts using a 240 ohm resistor. Then use the program in the 7 segment display tutorial and each display should light up with the same thing as in the other tutorial.

Now comes the trick to putting a different number on each display. The basic idea is to only turn one display on at a time. So we write the number to all the displays, turn on one display, then turn off that display and go to the number for the next display. We turn the displays on and off using NPN transistors. Each display has a transistor that provides power. The transistor is turned on and off by an output pin from the 2051. This way we can use 4 outputs to turn on the 4 displays one at a time. This lets us control 28 LEDs with only 11 outputs. 

To add in the transistors, connect the collector of each transistor to the 12VDC power supply. Then connect the emitter of one transistor to pin 3 of the top display. Connect the base of this transistor to P3.2 (Pin 6) of the 2051. Connect the next transistor's emitter to pin 3 of the next display and the base to P3.3 (Pin 7). Connect the next transistor's emitter to pin 3 of the next display and the base to P3.4 (Pin 8). Connect the final transistor's emitter to pin 3 of the bottom display and the base to P3.5 (Pin 9).

Finally, add in the switches by connecting them both to ground. Then connect one to P3.0 (Pin 2) and the other to P3.1 (Pin 3). P3.0 will be our "Set" input and P3.1 will change the value while setting.

The software for the 2051 is 7segclk.asm. It is included on the software CD with the Microcontroller Beginner Kit. Compile the program using TASM and load the hex file into the 2051. Put the 2051 into the circuit and connect the power.

All the parts required for this project are included in the  Microcontroller Beginner Kit.

Back To Tutorials Menu
Previous - Using a Switch as an Input to the Microcontroller
Next - Using 8051 RAM (The Game of Simon)
Other - Using the 8051 EEPROM
Other - Using a Light Sensor

Catalog -- Support -- Privacy Policy -- About Us
This page last updated on December 2, 2004.