Six-key electronic piano with one NE555 timer

Press a key and the speaker sings a note. Each of the six push buttons connects its own resistor into the timing network of an NE555 timer, so every key sets a different pitch: C4 262 Hz, D4 296 Hz, E4 333 Hz, F4 352 Hz, G4 398 Hz, A4 446 Hz. With no key pressed the speaker is silent.

  • 10 parts
  • 6 wiring steps
  • No code needed
  • 5 V supply

Quick answer

The short version. Every pin is in the full wiring below.

What you need

  • NE555 timer
  • 6 push buttons
  • Six key resistors, 5 % 1/4 W: 5.1 k
  • 3.9 k resistor, 5 %, between plus and pin 7
  • 390 nF capacitor, film or ceramic, 16 V or more
  • 100 nF ceramic capacitor
  • 33 ohm resistor
  • 470 uF 10 V electrolytic capacitor
  • Small 8 ohm speaker
  • 5 V DC supply, regulated, 2 A module

How to wire it

  1. Supply plus (red) to NE555 pin 8 (VCC) and pin 4 (RESET), to the top of the 3.9 k resistor, and to one end of the 100 nF capacitor.
  2. Supply minus (black) to pin 1 (GND), to the other end of the 100 nF capacitor, to the minus end of the 390 nF capacitor, and to the speaker's second lug.
  3. The other end of the 3.9 k resistor to pin 7 (DISCH).
  4. Each button's right leg goes to its own resistor (5.1 k, 4.3 k, 3.6 k, 3.3 k, 2.7 k or 2.2 k, top to bottom).
  5. Pin 3 (OUT) to the 33 ohm resistor, then to the plus (long leg, no stripe) of the 470 uF capacitor.
  6. Pin 5 (CONT) stays open.

Before you power it: Everything here runs on 5 V DC from a regulated supply. Press one key at a time: two keys together put two resistors in parallel and raise the pitch.

A purple DIY Electronic Piano title above a column of six push buttons, each with its own resistor (C4 5.1k, D4 4.3k, E4 3.6k, F4 3.3k, G4 2.7k, A4 2.2k). A fingertip presses the E4 button and a readout shows E4 333 Hz. To the right an NE555P with a 3.9k resistor and a 390 nF capacitor, a 33 ohm resistor, a 470 uF capacitor and an 8 ohm speaker with sound arcs, and a Wirecora 5V DC supply at the bottom
The circuit as wired in the Short. Every wire end is a real pin; the netlist was checked before the video went out.

Parts list

  • NE555 timer (for example TI NE555P, DIP-8), 5 V supply
  • 6 push buttons, 6 x 6 mm tactile type, normally open
  • Six key resistors, 5 % 1/4 W: 5.1 k (C4), 4.3 k (D4), 3.6 k (E4), 3.3 k (F4), 2.7 k (G4), 2.2 k (A4)
  • 3.9 k resistor, 5 %, between plus and pin 7
  • 390 nF capacitor, film or ceramic, 16 V or more (marked 394), the timing capacitor
  • 100 nF ceramic capacitor (marked 104) across the supply at the chip
  • 33 ohm resistor, 5 %, 1/4 W, in series with the speaker
  • 470 uF 10 V electrolytic capacitor (the stripe is the minus side)
  • Small 8 ohm speaker
  • 5 V DC supply, regulated, 2 A module

Wiring, step by step

  1. Supply plus (red) to NE555 pin 8 (VCC) and pin 4 (RESET), to the top of the 3.9 k resistor, and to one end of the 100 nF capacitor.
  2. Supply minus (black) to pin 1 (GND), to the other end of the 100 nF capacitor, to the minus end of the 390 nF capacitor, and to the speaker's second lug.
  3. The other end of the 3.9 k resistor to pin 7 (DISCH). Pin 7 also goes to the left leg of every one of the six buttons.
  4. Each button's right leg goes to its own resistor (5.1 k, 4.3 k, 3.6 k, 3.3 k, 2.7 k or 2.2 k, top to bottom). The far end of all six key resistors joins one line, and that line goes to pins 6 and 2 (THRES and TRIG, tied together) and to the plus end of the 390 nF capacitor.
  5. Pin 3 (OUT) to the 33 ohm resistor, then to the plus (long leg, no stripe) of the 470 uF capacitor. The capacitor's minus (stripe) goes to the speaker's first lug.
  6. Pin 5 (CONT) stays open. Where two wires hop over each other in the picture they do not touch.

How it works

  1. The NE555 is wired as an astable oscillator. The 390 nF capacitor charges through the 3.9 k and the chosen key resistor, and discharges through the key resistor into pin 7. Each time it reaches 2/3 of the supply the output flips low, and at 1/3 it flips high again.
  2. Each button sits in series with its own resistor, so a pressed key puts exactly one key resistor between pin 7 and the capacitor. With no key pressed there is no discharge path and the chip cannot oscillate.
  3. The frequency is f = 1 / (ln2 x (3.9 k + 2 x R_key) x 390 nF). A smaller key resistor gives a higher note, so the keys further down the column play higher. The six notes land within 1.5 % of the equal-tempered C4 to A4 on paper, and within 1 % in a simulation of this circuit.
  4. Frequency and duty cycle do not depend on the supply voltage, because the thresholds are fixed fractions of it.
  5. The 33 ohm resistor and the 470 uF capacitor keep the NE555 output current at about 85 mA at start-up (the datasheet limit is 200 mA). Without the 33 ohm resistor the start-up surge would be about 370 mA. The capacitor also blocks DC, so no steady current flows through the speaker.
  6. The speaker gets about 10 mW, so it is quiet. An LM386 amplifier is the usual next step.

What the video simplifies

  • The hand, the yellow highlight on the pressed key's row, the sound arcs and the speaker cone movement are graphics. The cone is drawn pulsing at about 9 times a second; the real cone moves at the note frequency.
  • The readout shows the circuit's computed frequency. For example E4 shows 333 Hz; the equal-tempered E4 is 329.6 Hz.
  • The sound in the video is synthesised at the circuit's frequencies.
  • The speaker is drawn larger than a 10 mW toy speaker would be.
  • With 5 % resistors and a 10 % capacitor the notes can be off by several percent. Use 1 % resistors and a 5 % capacitor, or trim, for an in-tune piano. An error in the timing capacitor moves all six notes together.
  • Pin 5 is left open; if a real build is noisy, add 10 nF from pin 5 to ground.
  • Nothing was built for this video: the values were calculated, checked against the TI NE555 datasheet and simulated.

You found this by searching. Here's the whole path.

  1. Read how it works
  2. See it work
  3. Build it
  4. Show it
Next: see it work

Thirty seconds of video shows the circuit doing its job.

Then build it

Everything here runs on 5 V DC from a regulated supply. Press one key at a time: two keys together put two resistors in parallel and raise the pitch.

Then show it

Built it, or stuck halfway? Post a photo in the Wirecora Discord. Questions get an answer every day.