DIY Musical Keyboard

The idea is to design and construct an electronic musical keyboard with some functions, effects etc,. This is my old school project and I remake and modified it. It is fun.

There are many hobbyist’s musical keyboard circuits around the net.  Most design are based on 555 or some oscillator circuits. The limitation of these design are that this circuit generates only one tone at a time. To play a real chord, several keys  are to be pressed at the same time and generate multiple tones at the same times. Ie,. for 12 tones, there will be 12 frequency generators are required. If a keyboard has 48 keys, 48 tone generators are required.

This can be saved by 4060 CMOS logic chip. The 4060 is 14-stage ripple-carry binary counter/divider and oscillator. The internal function block diagram of 4060 from datasheet is as follows. Output Qn is the nth stage of the counter, representing 2^n, for example Q4 is 2^4 = 16 (1/16 of clock frequency) and Q5 is 2^5 = 32 (1/32 of clock frequency).

4060 IC functional block diagram (from TI data sheet)

The frequency of chromatic scale can be learned here.

There are a relation between the frequencies of octaves scales. The first octave of  C1 (16.3Hz) is half of second octave C2(32.7Hz) and so on. The 4060 IC can divide its clock frequency via Qn outputs. We will need 12 x 4060 tone generators and it will supports 7 octave as maximum (12×7 = 96 tones, bingo).

Thus, the initial design is like that. The design is composed of 12×4060 tone generators, a dsPIC for sound effect and control, an amplifiers.

Musical Keyboard block diagram

The first circuit is 4060 tone generators. The clock frequency can be calculated as f = 1 / (2.3xR2xC1). I plan to use 4 octaves (48 tones) and starting from C3(130Hz) to B6(1975Hz). You can choose what scales are used. For roughly calculation, the adjustable  frequency range of RxC circuit should be covered this selected range. For next expansion,  I prepared for 6 tones outputs in design.

Updated: thanks Rollicks for pointing the right frequency calculation f = 1 / (2.3xR2xC1).

4060 Tone generators circuit

The next circuits are simple 7805 power supply and LM386 audio amplifier. Nothing specials.

7805 5V regulator
LM386 audio amp circuit

The first step is preparing the physical key and PCBs. The keys are salvaging from old toy china made keyboard. Unfortunately  the switches from toy keyboard used matrix keys. So, I made a PCB for switches also.


Prepared switches bar with the original switches dimension.

And next switches assemblies,

And circuits and wiring,

Initial setup is finished.

Tuning the frequency, I used my Nexus 7 and gStrings tuner app :D.  Thanks the developer for such useful applications. Only one octave is required to tune. Once,the C3, C4 or one of any note is tuned and the rest will be in-tune atomically because of frequency divider.

Finally, after some weekends and many coffees, the first phase design is like this.

The next step:

– You may notice the blank space at the moddle of board. Yes, this is for dsPIC sound effects and control

– I have to make a upside cover also.


– The switches are not ease as original keyboard. I have to find more proper solution for final design.

– The LM386 amp is not matched with tones. I notice some distortion in low volume. I will replace with a proper stereo amplifier in next phase. I want the left and right octaves with separated effect and sound output.

For now, it is ready for open 7400 logic competition because it has only discrete logic :).


27 thoughts on “DIY Musical Keyboard

    1. Hi Yaqub,
      This is smallest schematic. You need 12x 4060 oscillator circuits to generate 12 music notes. you cannot reduce 4060 ckts. You can only reduce how many keys or octaves are used. Eg, 12 keys (one octave), 24 keys (2 octaves) ,…,72 keys (6 octaves). You may left LM386 Amplifier circuit if you already have another suitable amplifier.
      keep in touch. this is a still developing project. Now, I am working on sound effects parts.

  1. Hi,
    I just need one octave (mid range), and i have no idea on the electronics part but i can get whatever is needed and solder, just need a simplified version 🙂 please do help. Since I have no idea on the electronics part it will be difficult for me to cut down from your bigger diagrams shown, it will be much helpful if you can just email or post the circuits and schematics just for an octave. thanks much.

    Rajthilak K

  2. Hi there, awesome project. Could you please post the files for the PCBs? Or are you waiting until you have a finished version of the project?

  3. Hi, I love your keyboard! I’m wondering about a couple of things. Your Schematic says 0.01 capacitors are to be used for the timing capacitors, am I to assume that is a 10 nF? Also, the datasheet for 4060 says that frequency is f = 1 / (2.3 * R2 * C1) but you use f = 1 / (2 * Pi * R2 * C1), which do I use, sorry but I am a total newbie.

    1. Hi Rollicks,
      Yes, 0.01 uF is equal to 10 nF.
      You are right, the correct freq calculation is f = 1 / (2.3 * R2 * C1). Some data sheet note that f = 1 / (2.2 * R2 * C1). Thanks for pointing this. Really, I adjusted variable resistor, R2 until the right freq is tuned. Calculation is roughly done to guess approximately whether the whole octave is cover by R2xC1.

  4. How can sound effects be added to the circuit for it to be played as that particular instrument. thank you.

    1. Hi,
      My first plan is to add dsPIC for sound effect but I cannot implement it yet. It is still one of my ongoing project. If I have a little spare time, I will do it.

  5. Hi, have you managed to work out the algorithm for identifying each sound frequency? im referring to the programming of the dspIC.

    1. Hi Nigel,
      I have tested some sound effects such as echo, distortion, fuzz etc. I use Audio and Speech Lib from Microchip and it is straight forward. I don’t write own code for effects or no need to identify each freqs. I cannot finished actual circuit at the moment. I will release codes when it is ready but still under day jobs loading and it is one of my pending project yet.

      1. Hi Oakkar7

        If I leave out the dspIC and only use the tone gens how different will the output sounds be like? Can i play multiple chords at the same time?

      2. Hi Shaun,
        It can be but you will need
        1# an algorithm for mixing/adding 2~8 freq in dsPIC. You need to mix different freqs by software before cord tone is leave out.
        2# better choose dsPIC with internal DAC such as dsPIC33FJ64GP802

        My initial design is to generate tones/cord by using only discrete parts because this is aimed an entry for
        After a basic design is finished, I only used dsPIC for sound effects.

  6. hi oakkar7,

    why do you need to connect multiple diodes at the output of the tone generators? does it affect the sound produced by the audio amplifier? Please advise.

  7. Greetings Oakkar7,
    That is one nice project. I have been searching for something like this for a long time. Thank you 🙂 .
    As far as I know, the circuit will generate a square wave. Can you please let me know how to produce a ‘piano sound’. Do I have to record the samples in some register(of uC or some other controller?) and send it when the key is pressed? If yes, can you please guide me through it.

    Thanking you in anticipation!! 🙂

    1. Dear Harshit, It is just an old school project with very basic parts and very simple method. Yes, its produce only square wave sound. My initial plan is to use dsPIC for sound effect such as piano sound. But it is still pending projects of mine. You can check available lib at Microchip website as a starting point cheers,

  8. Hi okkhar7,
    I am designing a new touch button keyboard completely different from the standard music keyboard. This allows for blind people to learn logically.
    Do you think you can supply me a very basic circuit board
    1/ that can wire up a speaker,
    2/ have individual pitch terminals in a row able to be soldered to wire up to 2 octaves in chromatic sequence for each separate switch button.

    alan le chong

  9. Hi oakkar7!
    I’m really interested in making your keyboard for a school project. Is there a parts list you could post? I’m a newbie to working with circuits, so I’m having a hard time figuring out what you used. Thanks for your time!

  10. Hi oakkar7
    I’m interesting in trying to build your project, but I am very new to building circuit. Do you have a parts list for this project? Thanks for your time.

    1. Hi Christ,
      It is unfinished circuit although it can use as minimal tones without effect.
      Pls see circuit 1,2,3(tones, power and amp) for required parts, that all for now.

      1. hi i recently found an old accordion but the bass buttons where damaged so i gutted the bass side
        i added a series of 12 button switches and a rs232plug to wire an old yamaha keyboard any ideas like to hear from you thanks

  11. It would be cool to have a keyboard that had a tone which would say the actual letter names of notes A, B, C , D, E, F, G for the white keys or naturals…then for the flats or sharps (black key notes), I guess I would just make the letter sound for them or for the notes…
    Bb/A# = baa (pronounced like the “baa” in baa baa black sheep)
    { or a B sound instead like Buh}

    Ab/G# = gaa (pronounced as “gaa” like a baby saying goo goo “gaa gaa” )
    (or prounounced like GOggle or GAwk)
    { or a G sound instead Guh}

    Gb/F# = Faa or Fuh or Fi (like Father, Fun, Fib)
    { or an F sound instead Ffff or Fuh}

    D#/Eb = Daa (pronounced like “dau’ in DAUghter)
    Eh (like Eh, or Egg, or pronounced like the “De” in Devil)
    { or an E or D sound instead such as a short E sound or Duh sound}

    C#/Db= Caa (pronounced like a crow making a Caa sound
    or like “Cau” in the word caught)
    { or a hard C cound cuh}

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s