Digital Alarm Clock Circuit

From Makerpedia

Revision as of 05:49, 23 November 2025 by Ajhg (talk | contribs) (Created page with "<small>by Livi Peters</small> ----- __NOTOC__ {{DISPLAYTITLE:Digital Alarm Clock Circuit}} Digital Alarm Clock Circuit <div class='overview'> == Project Overview == In this project, we will build a 24-hour digital alarm clock on a PB505 prototyping board using basic electronics components. The clock includes: four 7-segment LED displays that show hours and minutes, a 60Hz alarm buzzer, and 8 logic switches used to both set the desired alarm time...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

by Livi Peters


Project Overview

In this project, we will build a 24-hour digital alarm clock on a PB505 prototyping board using basic electronics components. The clock includes: four 7-segment LED displays that show hours and minutes, a 60Hz alarm buzzer, and 8 logic switches used to both set the desired alarm time and turn the alarm off (so, it successfully wakes you up and gets you out of bed in the morning!). The prototyping board’s built-in transformer is used to power the clock, so everything you need to build this circuit is found conveniently on the PB505. Throughout the tutorial, refer to the circuit diagrams provided and the pinout diagrams in the “Additional Files” section!

Tools and Materials

  • PB505 Prototyping board (or, you can use a breadboard, 8 logic switches, 1 speaker, a 12.6 VAC Center-tapped transformer, 1 debounced push button, and a DC power supply capable of supplying +15V, -15V, and +5V)
  • LM311 Differential comparator IC (x1)
  • SN74LS107 Dual J-K flip-flop IC (x6)
  • SN74LS90 Decade counter IC (x4)
  • SN74LS47 BCD-to-7-segment decoder IC (x4)
  • SN74LS08 Quad 2-input AND gate IC (x3)
  • Common Anode 7-segment display (x4)
  • Resistors: 200 Ω-470 Ω (x28), 20 kΩ (x1), 400 Ω (x1), 1 kΩ (x1)
  • Capacitors: 10 nF (x1), 10 uF (x1)
  • SN74LS04 Hex inverter IC (x1)
  • 555 timer IC (x1)
  • SN74LS688 8-bit magnitude comparator IC (x1)
  • LF411 Op-amp
  • Function generator and BNC cable (for testing purposes)
  • Oscilloscope and probe (for testing purposes)
  • A collection of wires


Step-by-Step Instructions

First, you will build one counter circuit on your prototyping board. The circuit diagram is depicted below, using one SN74LS90 decade counter, one SN74LS47 7-segment decoder, one common anode 7-segment display, 7 resistors between the values of 200 and 470 Ω, one debounced push button, and one 1 kΩ pulldown resistor. This circuit will count from 0-9 according to the number of pushes of the button. Make sure that none of your resistor leads are touching, or else the display might not read the correct numbers! This counter module will provide the base for each of the 4 sections of your clock’s display.

Repeat Step 1 and build a second counter circuit below your first one. The top counter circuit represents the “tens” digit for your alarm clock’s minutes display, and the bottom counter circuit represents the “ones” digit for your alarm clock’s minutes display. Remove the button and pulldown resistor from the circuit, and instead connect pin 11 of the bottom 74LS90 IC to pin 14 of the top 74LS90 IC. This ensures that, when the “ones” digit goes from 9 back to 0, the “tens” digit gets clocked one time. Rather than clocking the two counters with button pushes, create a square wave using the function generator, and connect the output to pin 14 of the bottom 74LS90 IC. I found it helpful to build the circuit initially with a higher frequency signal than the 1/60 Hz signal that we will eventually use to clock the circuit one-time-per-minute, so I set my function generator to produce a 1 Hz, 5 Vpp square wave. Feel free to adjust it during different testing stages of the clock! Now, the circuit counts to 99 via pulses from the function generator, then resets to 00. So, if you used a 1 Hz signal, you essentially have a 99 second clock!

Well, we don’t count minutes (or seconds) up to 99, we count them up to 59, so now we need to reset the displays once 59 is reached. To do this, wire up a 74LS08 AND gate. I chose to situate the IC in between the two 74LS90 ICs. Connect pins 8 and 9 of the top 74LS90 IC to the A (pin 13) and B (pin 12) inputs of one AND gate, respectively. Connect pins 2 and 3 of the top 74LS90 IC to the output (pin 11) of the AND gate. This ensures that the counter will reset to 00 when the clock “tries” to strike 60. Check that your displays behave as you would expect, counting from 00 to 59, then resetting back to 00, and if they do, proceed!

Repeat steps 1 and 2 to build two more counter circuits to the right of the two that you already have. These will represent (top right) the “tens” digit for your alarm clock’s hours display and (bottom right) the “ones” digit for your alarm clock’s hours display. I chose to mirror the wiring of my first two counter circuits so the LED displays could be closer together (and thus easier to read), as shown in the diagram, but wiring choices are completely up to you. Rather than counting to 59 for these displays, we want to count from 00 to 24, incrementing by 1 each time the minutes displays reset from 59 to 00. To do this, connect the output (pin 11) of the AND gate to pin 14 of the bottom right 74LS90 IC. Connect pin 11 of the bottom right 74LS90 IC to pin 14 of the top right 74LS90 IC. Wire up a second 74LS08 AND gate IC in between the two rightmost 74LS90 ICs. Connect pins 2 and 3 of both of the rightmost 74LS90 ICs to pin 8 of the second AND gate. Connect pin 8 of the bottom right 74LS90 IC to pin 9 of the second AND gate. Lastly, connect pin 9 of the top right 74LS90 IC to pin 10 of the second AND gate. Your clock should count from “00 00” to “23 59” then reset back to “00 00,” at a speed set by your function generator’s output. The key wires connecting the different modules of the circuit are highlighted in pink in the diagram below.

Next, we need to add in the alarm component! For my circuit, I built an hour-only alarm, since most people just set an alarm on-the-hour to wake up in the morning (note that if you want to include an alarm setting for individual minutes, you will need an additional 8 logic switches and 8-bit magnitude comparator IC). First, wire up a SN74LS688 8-bit magnitude comparator IC, and connect the P inputs to the corresponding logic-switch outputs on your board. This IC is active low, so its output swings low when 8 P inputs match 8 Q inputs. The diagram below shows the correct wiring that makes switches 1-4 correspond to the binary outputs for the hours “ones” digit of the alarm clock, and switches 5-8 correspond to the binary outputs for the hours “tens” digit of the alarm clock. When the outputs of the switches match the outputs of the current hours on the clock, the output of the magnitude comparator will swing low. As one example, if I wanted to set my alarm for 9 AM, I would flip the switches that correspond to 9 in binary (aka 1001), so I would flip switches 1 and 4 to be high, and leave switches 2, 3, 5, 6, 7, and 8 low. When the clock reads 09 00, the output of the 8-bit magnitude comparator swings low. Feel free to check that the magnitude comparator does what you expect by flipping different switches and checking the output when the clock matches the switch input. The alarm user needs to be familiar with 4-bit numbers from 0 through 9 in binary! Also, to turn the alarm off, the user can flip various switches up or down so that the inputs to the 8-bit magnitude comparator will no longer match. Flipping switches 5-8 up will turn the alarm off indefinitely, because the hours “tens” digit will never match this input. This is the alarm clock’s “Alarm off” switch!

Now, we want our circuit to output some sort of sound when the alarm is supposed to go off. To do this, we need a sufficiently low-impedance digital high/low alternating signal to provide a frequency to the speaker on our board. You can do this with the function generator, but I chose to automate the process so the circuit will run by itself without an external function generator. The first step in the process is building a circuit with a 555 timer in astable mode. The circuit diagram below shows the values of resistors and capacitors that I used to result in a 60Hz square wave output. The output frequency can be controlled by changing the capacitors and resistors according to the formula: f = 1.44 / ((R_1 + 2R_2)*C). The 555’s output cannot directly drive the speaker, so next you need to use an LF411 op-amp to lower the impedance of the signal. Make sure the top rails of your prototyping board are set to +15V and -15V, and attach pins 7 and 4 of the LF411, respectively, to the power supply rails. Connect the output of the 555 circuit to the noninverting input of the op amp (pin 3), and power the op amp as shown in the circuit diagram. Feed the op amp’s output into another AND gate, either by adding a new 74LS08 IC or by using one of the existing ICs on your board (I opted to add another 74LS08 IC so that I would not have to use long jumper wires, but the choice is yours!). And, we can turn back to the 74LS688 IC. The output is low at the time that the alarm goes off, but we want a logic high signal to feed into the AND gate that we just added. So, feed the 74LS688 output into a NOT gate (I used a 74LS04 Hex inverter IC), and then feed the output of the NOT gate to the other input of the new AND gate. So, when the time on the clock matches the alarm setting, the output of the 74LS688 swings low, it feeds through a NOT gate and changes to high, then it enables the output of an AND gate connected to our 555 and LF411 op amp. Check that the output of the AND gate behaves as you would expect when the alarm is set to go off! Lastly, connect the speaker on your board to the alarm circuit. One end of the speaker should be connected to ground, and one end should be connected to the output of the AND gate, as shown in the diagram below.

Check the output of your alarm clock for different settings of alarm times! Currently, if you set the function generator to output a 1/60 Hz square wave, you have a 24-hour alarm clock built! All together, the circuit diagram so far is shown below. Before the next step, make sure that the alarm is functioning as you would expect it to.

Next, we will switch from the function generator to the on-board transformer to power the circuit. “Real” digital alarm clocks that you might buy at the store don’t use some sort of external timing device like a function generator, they just use internal circuitry and a voltage from the wall. Thus, we will make our alarm clock self-contained in the same type of way! Your prototyping board has a built-in transformer at the top that has 3 pins– a red one, a yellow one, and a blue one. First, connect the yellow one to ground, and wire up an LM311 comparator below the transformer on your board. Supply the LM311 using the +15V and -15V rail voltages, and connect the red transformer pin to the noninverting input of the comparator. Use a 20 kΩ pullup resistor on the output (pin 7), and otherwise wire the comparator according to the circuit diagram. Be careful not to accidentally supply more than +/- 15V to the comparator’s inputs or rails, and be sure to use the yellow transformer pin instead of the blue one. The LM311 cannot handle voltages higher than 15V and I learned from experience that they are very easy to burn out!

Divide the frequency of the transformer’s signal using a cascade of J-K flip-flops. If you measure the frequency of the output signal from the LM311 using your oscilloscope and probe, you will find that it is 60 Hz, which is much too fast for our alarm clock. So, we need to build a chain of divide-by-2 circuits to provide a 1/60 Hz signal to the clock pin (pin 14) of our first 74LS90 counter, corresponding to the minutes “ones” digit. I found that a chain of 6 dual J-K flip flop IC’s (74LS107) successfully divided the frequency down to where the alarm clock minutes changed after 56 seconds. While this is not the most precise clock in the world and there may be more efficient ways to achieve this (such as using a crystal oscillator and trimming capacitors), for my demonstrative purposes, this timing resolution was accurate enough for me! To divide the frequency, feed the output of the LM311 into the clock 1 pin (pin 12) of the first 74LS107 IC. The J and K inputs of both flip-flops, as well as the clear pins, will be held high, and the output of one J-K flip-flop feeds into the clock input of the next J-K flip-flop, creating a simple divide-by 2 chain. Continue the pattern of output→clock, output→clock for 6 74LS107 IC’s (or 12 J-K flip-flops), as shown in the circuit diagram below.