Projects

Kids' Basics: Music Maker

Daniel Koch

Issue 43, February 2021

Have some fun and annoy your family with this eight-note music maker.

BUILD TIME: 45 MINUTES
DIFFICULTY RATING: BEGINNER

Adult supervision recommended for cutting and hot melt gluing.

This month, we’re putting our own spin on something of a classic project. Electronic ‘pianos’, ‘organs’, or ‘keyboards’ have been around in one form or another nearly as long as anyone has been designing electronic circuits for kids. We’re presenting one that is a little different in construction, operation, and adaptability.

We feel it is a significant stretch to call this device a ‘piano’ or any other instrument, because we have not calibrated the sounds to be actual notes, or have the right amount of separation to be an octave. If you don’t know what that means, then you probably won’t care. However, if you can play music and do know what notes should sound like, and how far apart they should be, you’ll be able to adapt our project very easily. You will even be able to expand it to make one with two or more octaves in one circuit.

INSTRUCTIONS AND ADVICE

We encourage you to read all the way to the end of the article before you build. Not only will you then have a better feel for the overall picture as you build, but we sometimes discuss options or alternatives that you will need to have decided on.

You will need some basic hand tools for most builds. Small long-nosed pliers and flush-cut side cutters meant for electronics are the main ones. Materials like tape or glue are mentioned in the steps, too. We always produce a tools and materials list if you have to go shopping, but anything that is lying around in most homes is just stated in the steps.

As always with Kids' Basics, we're building on a solderless breadboard. We avoid soldering to make Kids' Basics accessible to more people, but having an adult around can still be helpful. You won't need any particular skills besides being able to identify components at a basic level, and even then, we help as you go along. If, for example, you don't already know what a resistor is, you'll probably be able to work it out from the photos and description in each step.

We do provide a schematic or circuit diagram but this is just helpful if you already know how to read one. Don’t stress if you have never learned, but take the chance to compare the digital image of the breadboard layout (which we call a 'Fritzing' after the company that makes the software) to the schematic and see if you can work some things out. You can make this project from the Fritzing and photos alone. You might also like to check out our Breadboarding Basics from Issue 15.

There is a “How It Works” section after the build, but you don’t need to understand it to get a working build. We have a “Where To next” section as well if you want to modify, expand, or alter your build, but again, it’s not essential.

You'll need a corrugated cardboard box to cut up for the keyboard.

Parts Required:Jaycar
1 x Solderless BreadboardPB8820
1 x Pack of Breadboard Wire LinksPB8850
2 x Plug-to-plug Jumper Leads *WC6027
1 x 100Ω Resistor *RR0548
8 x 10kΩ Resistor *RR0596
1 x 1MΩ 16mm PotentiometerRP7524
1 x 10nF MKT Capacitor #RM7065
1 x 100nF MKT Capacitor #RM7125
1 x 330μF Electrolytic CapacitorRE6188
1 x NE555 Timer ICZL3555
1m Twin Core Light Duty Speaker WireWB1702
1 x Small speakerAS3000
1 x 9V BatteryPH9232
1 x 9V Battery SnapSB2423

* Quantity shown, may be sold in packs. # We use MKTs but other types of the same value will work. % Different value but will still work.

The Electronics Build:

Step 1:

Place the breadboard in front of you with the outer red (+) rail away from you and the outer blue (-) rail closest to you. Install the NE555 IC with its dot or notch facing your left. Also, add the wire links which join the matching supply rails.

Step 2:

Install the three wire links which join pin 2 of the 555 to pin 6. Also install links from pin 8 to the upper red (+) rail, pin 4 to the lower red (+) rail, and pin 1 to the lower blue (-) rail.

Step 3:

Insert a 100Ω resistor brown-black-black-black- -brown, at pin 3 of the 555, and a 10k resistor at pin 6. Add the wire link shown, too. Also install a 10kΩ resistor brown-black-black-red- -brown, between pin 6 and a spot to the right of the 555, and a wire link to join the other end of this resistor to the row one spot over from where it ends. In other words, skipping one row.

Step 4:

Add a 100nF capacitor between pin 5 of the 555 and the upper blue (-) rail. Add a 10nF capacitor between pin 2 and the lower blue (-) rail.

Step 5:

Install a 330μF Electrolytic capacitor with its positive lead connected to the 100Ω resistor and its shorter negative lead, with the stripe, to the left. Add a 16mm 1MΩ potentiometer so that two of its legs line up with the resistor and wire link from step 3.

Step 6:

Cut a plug-to-plug jumper wire in half, bare the ends, and twist them through the terminals of a small speaker. Tape the joins.

Step 7:

Cut another jumper lead in half, and bare then ends of that and a metre of speaker cable. Twist the jumper halves onto one end and tape the joins.

Step 8:

Wrap one free end of the speaker wire around a nail, and tape it. Wrap the other around a thumb tack.

Step 9:

Take eight 10kΩ resistors brown-black-black-red- -brown, and wrap the leads around the tips of small long-nose pliers to create wound loops. Lay them end to end, so you can find a total length of your keyboard.

Step 10:

Cut enough layers of cardboard to fully hide the pins on your thumb tacks. We needed four layers. Glue the rectangles together with hot melt glue.

Step 11:

Slide one resistor’s loop onto a thumb tack and push it into the cardboard at one end. Slide the next resistor’s loop over the pin of the next thumb tack, then press it into the board so it slides through the other loop of the first resistor.

Step 12:

Repeat this process until you have one resistor leg left. Push the thumb tack with the speaker wire into this one. Take the thumb tack with the speaker wire on it from step 8, and push it through the loop of the last resistor.

Step 13:

Insert the wire from the resistor/thumb tack string to the 1MΩ potentiometer. Plug the wire from the nail stylus into pin 3 of the 555. Also install the speaker wires, one to the negative striped leg of the 330μF Electrolytic capacitor, and the other to the lower blue (-) rail.

Step 14:

Insert the wires from a 9V battery snap, the red wire going to the upper red (+) rail and the black wire going to the lower blue (-) rail. The rails are joined and the battery snap wires could go side by side, but separating them means they’re less likely to short circuit if they come loose.

TESTING IT

Connect a battery and touch the stylus to one of the thumb tacks. If you hear sound, you’re nearly done. If you don’t, unplug the battery and check all of your connections. Double check the breadboard connections, but also the thumb tack connections.

If you do get sound, turn the potentiometer clockwise, all the way until it stops. Touch the stylus against each thumbtack from one end to the other, and listen to the sounds. Now turn the potentiometer all the way to the other end of its travel, and repeat the process. Then, do it again with the potentiometer set roughly in the middle of its travel. The sounds from each thumb tack should change each time by a similar amount, up or down, but the whole lot will be different depending on where the potentiometer is.

How Does it Work?

The circuit is yet another use for the NE555. However, we haven’t used it this way before. As we discussed in Kids’ Basics Issue 42, there are many labelling possibilities for this IC. That article is available online if there are any dramas. As always, you don’t need to read or understand this part to build a working circuit, but learning is the overall aim. You will need a little more background knowledge to follow this bit, but not much, and the ability to read circuit diagrams.

The 555 in this case is set up as an oscillator, which means it turns on and off over and over again until stopped or the power is removed. The term oscillator covers circuits which make waves as well, but turning on and off will do for now. When a 555 is run as an oscillator in astable mode, as it is referred to, the usual method is to have a resistor between Vcc (the positive voltage supply rail, both of the red (+) rails), and pin 7 of the 555, which is called the Discharge pin. More on that later. There is another resistor between pin 7 and pin 6, the threshold pin. Pin 6 is connected to pin 2, which is the Trigger pin.

When power is first applied, current flows through both of these resistors to charge the capacitor. The output pin 3 is high. As the capacitor charges via the two resistors, the voltage across it (the other side is connected to ground) rises. Inside the 555 is a device called a ‘flip flop’, which changes state between on and off. In the case of the 555, the flip flop is activated by pins 6 and 2, the threshold and trigger pins respectively. When the voltage on the capacitor, which is connected to both pin 6 and pin 2, reaches two thirds Vcc, the comparator (another internal device) senses this, and the flip flop changes state. The graph we have shown this on is very simplified, and does not show the capacitor charge curves or the difference in charge and discharge times described next.

This causes the output pin 3 to go low, and also causes an internal transistor to turn on, which grounds pin 7, the discharge pin. The capacitor now discharges through only the resistor between pins 6 and 7, so the timing is different to the charge cycle. When the voltage across the capacitor reaches one third Vcc, the comparator connected to pin 2, the trigger pin, resets the flip flop. Now output pin 3 goes high, the internal transistor turns off and stops pin 7 discharging, and the cycle repeats. The rate is set by the values of the capacitor and the two resistors. The charge cycle depends on CT, RA, and RB, while the discharge depends on CT and RB only.

That’s under normal circumstances. There are other ways to make the 555 oscillate as well, but most are similar. This circuit is completely different. Here, the capacitor C2 is connected to pins 2 and 6, but the resistor is made up of the 10kΩ resistor RX, 1MΩ potentiometer VRX, and whichever other resistors are between it and the stylus. If the stylus is touching the last thumb tack, only RX and VRX are involved. As you move the stylus down the chain of resistors, the resistance increases as the current flows through more and more resistors. So, that’s why the resistance varies, but where is the charging current for C2 coming from and its discharge current going to?

The Stylus is connected to pin 3, the output pin. Remember that pin 3 is high when power is first applied, and stays so until the internal flip flop is set? That means current flows from it, through the stylus, to the resistor network. It flows along the network, meeting a different resistance depending on which thumb tack you place the stylus on, and charges the capacitor. Because the capacitor charges at a different rate due to the difference of resistance at each thumb tack, different frequencies are produced.

However, pin 3 can also ‘sink’ current when it is low. That means current can flow into it and then to ground, just like the discharge pin 7 when it is being used. It flows along the same resistor network, meaning the discharge time is the same as the charge time. The rate at which this circuit switches on and off (oscillates) is dependent on the resistor network, and capacitor C2. The small value of C2 means that the circuit oscillates at a frequency that human ears can hear. With larger capacitor (or resistor) values, the rate would slow down, because the capacitor would take longer to charge and discharge. You could make that rate slow enough to see, and make this a variable speed flashing light.

There are three other components connected to output pin 3. The 100Ω resistor limits current so that the 200mA current limit of pin 3 is nowhere near exceeded. The 330μF Electrolytic capacitor blocks all DC signals and feeds only AC (alternating current) signals to the speaker, because current only flows in a capacitor when it is charging or discharging. Then, there is the speaker itself, the other side of which is connected to ground. As pin 3 turns on and off with the oscillator cycle, current flows in the capacitor, which causes current to flow in the speaker coil.

Because there is no connection to trigger and threshold pins, this part of the circuit does not affect or alter the timing.

The rest of the circuit is just a means to an end. Pin 8 is the Vcc connection to the 555, while pin 1 is the ground. Pin 4 is the reset and must be connected to Vcc in Astable operation. Pin 5 is the control voltage and can be used to alter the threshold at which the 555 discharges. We don’t use it and keep it connected to ground with a 100nF capacitor to stop stray signals from affecting it.

A BIT OF MATHS TO TAKE IT FURTHER

It is worth discussing the timing maths of the circuit while we’re here. If you are going to modify your circuit to be closer to actual music notes, you’ll need this information. The frequency of the output at pin 3 is given by:

f = 0.72 ÷ (Rn x C2)

Where f is the frequency, 0.72 is a constant number, Rn is the resistance of the network in ohms, and C2 is the timing capacitor value in Farads. Note that we always work in whole base units. Ohms is fairly easy. Lower values are already in ohms, while something like 10kΩ means 10,000 because k means x 1000. Farads is a different story for most Kids’ Basics readers. The Farad is a big unit. We usually work in micro-, nano-, and pico-Farads. You are dividing by an extra thousand every time the unit name changes, so a millifarad (which is hardly ever used) is a Farad divided by one thousand. A microFarad, μF, is a Farad divided by one thousand thousands, or one million. It keeps going.

It gets harder when things are given in scientific notation. 5kΩ can be (but usually isn’t) written as 5 x 103. This means 5 x 10 x 10 x 10, or 5 x 1000. six picoFarads, for example, is 6 x 10-12. 10-12 means 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10 ÷ 10. It’s easier for most people to think of it this way: The little number is the number of places to move the decimal point to the right if it’s a positive number (no sign), or the number of places you move the decimal point to the left if it’s negative (has a minus sign, just like our 10-12). Remember, whole numbers end in a decimal point, too. We just don’t usually write it because there are no more meaningful numerals (called significant figures) after it. For example, 20 is actually 20.0. This becomes more relevant when you have a number like 2.2 x 103. In late Primary school, you may be taught to add the number of zeros on the small number above the 10 (called the power or index). This works for whole numbers like 20, but falls over when you have a decimal point as in the 2.2 example. If you have 2.2000, you haven’t changed anything. 2.2 x 103 is actually 2200.0

So, if you have a 10nF capacitor, and nF is 10-9, then you need to move the decimal place nine positions to the left to divide correctly. That’s 0.00000001 Farads. Note that because there is already a ‘0’ with place value in the number ‘10’, we don’t just add nine zeros between 10 and the decimal point like we can with whole numbers. The decimal point was already one place away from the ‘1’, on the other side of the ‘0’, like this: 10. We just don’t add that last zero when we write the decimal, because it has no place value, but we can to help explain it: 0.000000010. Now there are nine digits between where the decimal place was, and where it is now. This throws a lot of people.

We know that’s not easy to follow. A written explanation is never the best way to explain a concept like that. If it were a primary maths class, it would be a 45 minute lesson at least, with the full range of teaching strategies including supported examples.

Back to the maths of our circuit. f = 0.72 ÷ (Rn x C2). We can rearrange (or transpose, to use the maths term) this to get Rn = 0.72 ÷ (f x C2). This way, you can keep using the formula over and over, for the frequency you want for each note. Remember from above that 10nF is actually 0.000000001 Farads. So, if you want to make your first note B3 (note B of the third octave, we finally looked it up!), which is 247 Hz (Hertz, or HZ, is the unit of frequency), then you would need to calculate:

Rn = 0.72 ÷ (247 x 0.00000001), which is 291,498Ω. That means 291,498Ω between the first stylus point and pin 2. You’ll have to round that, but there is a 10,000Ω resistor between pin 2 and the wire to the keyboard, so that’s actually 281498Ω extra that you need, and that’s between the 10kΩ resistor and the first thumb tack. Set this with the 1MΩ potentiometer.

Then, you might want the 220Hz note A3. Plugging the numbers into the formula, Rn = 0.72 ÷ (220 x 0.00000001) = 327,272Ω for Rn. Remember, Rn is the total along the string, so it includes the 10kΩ resistor and 280,000Ω (rounded) set on the potentiometer. So, for the resistor between the first thumb tack and the second, round to the nearest thousand to get 327,000, and take away the 10,000 and the 280,000, leaving us with 37,000Ω. The nearest resistor value is 36,000Ω.

You can keep going in this pattern until you reach a full set of notes for an octave. Note also that you can add more than the eight notes if you want, to include sharps and flats (yes, we looked that up too!). Sorry that’s so long, but if you are a muso and want to build a keyboard with correct notes, you’ll want to know it!

WHERE TO FROM HERE?

What you do next depends on your musical knowledge. We have very little here in the DIYODE office. We love music, we just don’t know enough about playing it. That means we have chosen to make things easy to build by using the same resistors for the eight notes.

We described in the ‘A Bit of Maths To Take It Further’ section how to calculate the resistor values for specific notes. You could add a few more thumb tacks and have a full octave with flats and sharps included, calculated to give specific notes.

The other thing you could do is make multiple rows of thumb tacks, for different octaves. Each would have a different set of resistor values, and be connected at the end to the same place, the 10kΩ resistor at pin 2. This resistor provides an absolute minimum, keeping the frequency within human hearing range. This way, you could have a full piano’s worth of notes to choose from, although unlike a piano, you can only play one at a time: No chords. There is a schematic here for this, but we haven’t included resistor values because we have no idea what they’ll be. That depends on which octaves you choose. Note also that the 10kΩ resistor and 1MΩ between pin 2 and the keyboard are gone, replaced by a fixed resistor for each octave.

The final idea we had is to combine any of the above circuits with tactile or other pushbutton switches so you can play a keyboard with your fingertips rather than a nail or stylus. That would be a lot of wiring though, as each button would need one side to be wired to pin 3!

"...make multiple rows of thumb tacks, for different octaves."