This circuit plays the opening riff from "At Doom's Gate" using 555 timers, 7400-series logic, and some resistors and capacitors. It does that without a microcontroller, computer, or any software whatsoever.
The first version was built on breadboards, but I wanted to turn it into something more permanent.
The new version puts the entire circuit on a custom PCB. I also replaced the PAM8302 module with an LM386 audio amplifier and added six LEDs that show which musical note is currently being played.
The KiCad design files can be downloaded here.
The basic operation hasn't changed from the breadboard version.
The circuit can be divided into five main sections:
- Tempo clock
- Sequence counter and decoder
- Diode note matrix
- Pitch selection and audio oscillator
- Audio amplifier
The signal moves through the circuit like this:
555 tempo clock
|
v
74LS161
binary counter
|
v
74LS154
4-to-16 decoder
|
v
1N4148 diode matrix
|
v
74HCT14
|
+----> note LEDs
|
v
2 x CD4066
analog switches
|
v
555 audio oscillator
|
v
LM386
|
v
speakerSetting the TempoThe first NE555 is configured as an astable oscillator. A capacitor repeatedly charges and discharges through its timing resistors, causing the output to continuously switch between high and low.
This oscillator runs at approximately 7.33 Hz, producing a new clock pulse about every 136 milliseconds. A trimmer potentiometer allows the tempo to be adjusted while measuring the output frequency with a multimeter, oscilloscope, or logic analyzer.
This 555 doesn't generate any sound. It simply tells the rest of the circuit when it is time to advance to the next note.
Counting Through the RiffThe clock signal goes into a 74LS161N four-bit binary counter. Each pulse increments the counter by one.
Its four outputs feed a 74LS154N 4-to-16 decoder. The decoder turns the binary count into individual outputs, giving the circuit a separate electrical signal for every position in the riff.
The 74LS154 outputs are active-low. When the counter is at zero, Y0 goes low. On the next count, Y1 goes low, followed by Y2, Y3, and so on.
There are 16 possible states, but this section of the riff only uses 15. Y15 is therefore connected through a pair of 2N3904 transistors to the active-low CLEAR input of the counter. Reaching Y15 resets the 74LS161 to zero, and the sequence begins again.
A pushbutton provides a way to reset the sequence manually as well.
Storing the Music With DiodesKnowing the current position isn't enough. The circuit also needs to know which note belongs there.
That's the job of the 1N4148 diode matrix.
There are 15 positions in the sequence but only six different pitches:
- E2
- B♭2
- B2
- C3
- D3
- E3
Each decoder output is connected through a diode to one of six note buses. If several positions play E2, for example, all of those decoder outputs have diodes leading to the E2 bus.
The diode matrix is effectively the circuit's musical memory. There isn't a ROM containing a list of notes or software deciding what comes next. The sequence is encoded directly into the wiring.
Each note bus normally sits high through a pull-up resistor. When a decoder output is selected, it goes low and pulls the appropriate note bus low through its diode.
Selecting a NoteThe CD4066 analog switches used in the next stage need an active-high control signal, so the six note buses first pass through a 74HCT14 hex Schmitt-trigger inverter.
A selected note enters the HCT14 low and comes out high.
Each of those six outputs controls one bilateral switch inside a pair of CD4066 chips. Each switch, in turn, connects a different resistor and trimmer combination into the timing network of the second 555.
Only one pitch network is selected at a time.
The second 555 is another astable oscillator, but this one runs at audio frequencies. Its timing capacitor charges and discharges through the selected resistance, determining the frequency produced at its output.
Larger resistance values produce lower frequencies, while smaller values produce higher frequencies. That's how the same 555 can generate all six notes.
Adding Note LEDsThe PCB version adds an LED for each of the six pitches.
These are connected to the active-high note-select outputs from the 74HCT14. When one of those outputs goes high to activate its CD4066 switch, it also illuminates the corresponding LED.
That means you can now watch the circuit step through the music as well as hear it.
Connecting the indicators here also keeps them away from the second 555's analog timing network. The LEDs are monitoring the digital control signals rather than loading the resistor and capacitor network that determines pitch.
Tuning the Six NotesThe pitch resistors get the oscillator reasonably close to the desired frequencies, but fixed resistor values aren't accurate enough to tune the circuit by themselves. Component tolerances, the timing capacitor, the 555, and the CD4066 switches can all affect the final frequency.
Each pitch therefore has its own trimmer potentiometer.
The easiest way to tune them is to temporarily take the sequencer out of the equation and manually activate each CD4066 switch.
Turn off the power before removing or installing an IC.
First, remove the 74HCT14 from its socket. This disconnects the normal note-select signals from the six CD4066 control inputs. Each of those inputs has a 100 kΩ pull-down resistor, so with the HCT14 removed, all six switches default to off.
Power the board again and connect the ground lead of a frequency meter, multimeter with frequency mode, oscilloscope, or logic analyzer to circuit ground. Measure the output at pin 3 of the audio 555.
To tune a pitch, connect +5 V to the CD4066 control input for that note. This turns on only that analog switch and connects its resistor network to the audio 555.
The oscillator should now continuously generate that note.
Adjust the corresponding trimmer until the measured frequency is as close as possible to the target.
Repeat the process for all six pitches.
For each note, temporarily connect +5 V to the control pin shown above, adjust that note's trimmer while watching the measured frequency, and stop when it matches the target as closely as possible.
Remove the +5 V connection before moving on to the next note. Only one CD4066 control input should be driven high at a time.
Once all six pitches are tuned, turn the power off, reinstall the 74HCT14 in the correct orientation, and power the board back up. The sequencer can now select the calibrated pitches automatically.
The same basic approach can be used to set the tempo. Measure pin 3 of the tempo 555 and adjust its trimmer until the clock is approximately 7.33 Hz.
Replacing the PAM8302The breadboard prototype used a PAM8302 amplifier breakout board. It worked well, but using a module on the finished PCB seemed unnecessary when the amplifier could be built directly into the board. It also doesn't quite match the retro feel of the rest of the circuit.
I replaced it with an LM386, a small audio amplifier IC that only requires a handful of external components.
The square-wave output from the audio 555 passes through a coupling capacitor and a volume potentiometer before reaching the LM386 input. The coupling capacitor blocks the DC component of the 555 output, while the potentiometer allows the signal level — and therefore the volume — to be adjusted.
The LM386 amplifies that signal enough to drive the speaker. Its output passes through a large electrolytic coupling capacitor before reaching the speaker, since unlike the PAM8302 module, the LM386 output has a DC bias that needs to be blocked.
About the Author







Comments