Tuesday, October 23, 2012

Five Dollar Synthesiser (post in progress)

What do you get out of interfacing Arduino to a low cost keyboard -

UPDATE - New synthesis mode added - Auduino style grain synthesis

UPDATE - Listen to the five dollar synthesiser here - 

Why hack a cheap childs keyboad -
1) Three octaves or more of ready made piano style keys
2) A large number of general purpose buttons for configuring you synth engine, adding effects or controlling a sequencer

This post concludes with a sketch which will provide your keyboard with some interesting capabilities to experiment with -

3) Four different waveforms - sine, square, ramp and dirty triangle
4) An adjustable speed arpeggio mode, low speed = arpeggios, high speed = chord like effects, very high speed = spacey distortion
5) Arpeggio record and play back
6) Transpose function, this shifts the three octave keyboard up and down by upto 7 octaves to give full access to the 128 midi note range - its also used in the video to creating the sweeping Arpeggios.

7) Delay ! - the code now features a delay function which you can here in action in the video.

Quick demonstration of using transpose with arpeggios -

Interfacing a low cost keyboard to Arduino -

The keyboard I am using is available for around 5 to 10 dollars, any similar keyboard in this price bracket is likely to work in the same way so pick one up and prepare to plug in.

So whats inside your typical five dollar keyboard ?

The main features are two PCBs which connect the many buttons and keys in a matrix.

The top PCB has been turned over to show the buttons and connections.

The entire matrix of buttons and keys is accessible from the17 solder pads visible in the center of the top PCB. Through these 17 pads we can read the state of any of the 36 keys and 33 buttons on our example keyboard.

Your keyboard may have a different number of keys and buttons, but the concept will be the same - all of the buttons are connected in a matrix pattern and this matrix is used to read the state of the individual buttons.

In the top right of the picture you might be able to make out a small amplifier. This amplifier uses a LM386 Chip which has previously been featured on RC Arduino in the post 'Adding Audio To Arduino Projects', this drives a small speaker fitted in the keyboard.


Zooming in for a closer look
While it might not be obvious from the picture the 17 solder connections represent 9 rows of 8 columns.

When a button is pressed it makes a unique connection between a row and a column.

By reading the state of these unique connections we know which keys are currently pressed. 

The great thing about using a ready made keyboard is that someone has already built the matrix for us. This many buttons and keys to plug into our Arduino is an excellent deal - its even better when you consider that we can read these buttons using only 10 or less Arduino pins.

How can we read the buttons using only 10 pins ?

The solution is multiplexing. To do this we switch all of the rows off and then switch each one on in turn. We record which row is currently on and then read the column to see if any keys are pressed.

If we press the center key of the keyboard, our column pins will not read anything until row 3 is the active (on) row. Then we can then do some simple maths to get the key number -

key number = (row * number of pins in a column) + column;

20 = (2*8) + 4

How do we do this with Arduino ?

One approach to this would be to dedicate a digital output pin for each row and a digital input pin for each column. This can be done but its a huge waste of resources, we would also need to write code to manage the switching on and off (multiplexing) of all of these pins.

A 4017 Decade Counter is a low cost widely available chip that will do this work for us using only 2 pins from the Arduino.

This chip has previously been featured on RC Arduino as a means to drive upto 10 Servos from just two digital output pins. It is a chip with all sorts of uses - LED Chasers, input and output multiplexing and more. If you don't have any, order a few, they are about 30 cents each and I can guarantee you will find a use for them.


The 4017 Decade counter does exactly what we want -

1) Has ten outputs
2) It only activates one output at a time
3) It automatically figures out which output to turn off and which one to turn on in a repeatable sequence
4) It does this switching across the 10 outputs and all we have to do is simply set an output HIGH then LOW to tell it when to switch to the next row.

Upgrading your keyboard
Your keyboard almost certainly has an existing micro controller inside it. In the example keyboard the micro controller is encased in a blob of white plastic so there is no chance to identify it or reprogram it.

To upgrade the keyboard we want to access the keyboard matrix using our Arduino, in the case of the example keyboard the microcontroller is on a separate board which can easily be removed by desoldering. 

Before - The microcontroller PCB is fitted sideways into the main key matrix PCB.

After - The original micro controller replaced with a set of wires that we can use to access the key matrix from Arduino.

Once the original micro controller is disconnected from the key matrix we can solder in a set of wires in its place, these wires will be used to connect the Arduino and 4017.

The Schematic

Parts List - 
8 * Current limiting resistors ( whatever you have between 500Ohms and 1K Ohms)
8 * 10K Pull down resistors
10 Diodes
1 * 4017 Decade Counter
Connecting wire

The arrangement of resistors shown for pin 4 should be duplicated for the 8 columns (pins 4 to 11). The 10K resistor pulls the input down to ground when the switch is open, without this, the switch would be floating leading to inconsistent readings. The 680 Resistors is in series with the pin and is there to limit the current entering the pin when a key is pressed.

In pictures
Starting at the bottom of the picture each column is connect to ground through a 10K pull down resistor.

The keyboard columns are connected through the thin white wires in the center of the picture.

These are then connected to the white jumper wires at the top of the screen through 680 Ohm current limiting resistors.

Thats it for the columns

Starting from the bottom we have the keyboard rows connected through the thin white wires.

Each of these is connected through a diode to an output of the 4017 Decade counter.

The full circuit - 72 Keys from 10 Arduino Pins using just one IC, 16 Resistors and 9 Diodes - 

Later in the series we can introduce a shift register to bring the number of Arduino pins down to 5 from the current 10.

Key Scanning Code

In order to ensure the code is portable between the Arduino Mega, Uno, Leonardo, Teensy and Due, the code makes use of the DigitalIO Library. This is not as fast as using direct port manipulation or the DigitalPin library but it is around four times faster than standard Arduino digitalRead and digitalWrite functions - a useful saving.

The DigitalIO and DigitalPin libraries are the work of Arduino forum user FatLib16 whose name comes from fast SD Card libraries that FatLib16 has also created.

The DigitalIO and DigitalPin Libraries can be downloaded from the following link -


For a complete list of FatLib16's libraries see here -

Some of these will be interesting to explore in the future as a way to add a sample and playback capability to the 5 dollar keyboard.

Key Scan using DigitalIO Library

 for(unsigned char sRow = 0;sRow <= (KEYS/COL_PINS);sRow++)
    for(unsigned char sCol = 0;sCol < COL_PINS;sCol++)

      // read each column pin using an array of DigitalIO objects, its faster than digital read
      // and portable to UNO, Mega, Leonardo, Teensy, Teensy 3 and Due in the future
      // Direct port manipulation is faster, but not portable.
        unsigned char sKey = (sRow<<3) + sCol;

        // Do something with this key
     clockKeyScanCounter(); // clock the 4017 to scan the next keypad row

The Next Step

 The synth engine is provided by a single oscillator, using the library referenced in this post -


The next version will include a simulated patch panel to configure the oscillator paths for a wider range of sounds and effects.

For a zip file including the complete sketch and modular synth library, message me Duane B on the Arduino Forum.

Duane B


  1. Man I really love your project. You've done a great job of simplifying it and explaining it well. This is exactly what I've been searching the web for for a year now, something this easy to understand yet freakin awesome!!! I have 3 keyboards, a load of rock band controllers and a Mixman dm2 dj controller and an arduino UNO still wrapped up just waiting to be hacked for a bit the ol sonic madness. You are great, can't believe you don't have a million comments, this is brilliant.

    1. Investment plansPROMO PACKAGE �� BASIC Invest $70 earn $600 Invest $100 earn $1000  Invest $200 earn $2,000  Invest $300 earn $3,500  Invest $400 earn $4,500  Invest $500 earn $6,000 
      �� PRO  Invest $1,000 earn $15,000  Invest $2,000 earn $25,000  Invest $3,000 earn $35,000  Invest $4,000 earn $45,000  Invest $5,000 earn $60,000  Invest $10,000 earn $100,000. 
      �� PREMIUM  1BTC earn 5BTC  2BTC earn 10BTC  3BTC earn 16BTC  4BTC earn 22BTC  5BTC earn 30BTC. 
      MODE OF PAYMENT. Any, Suitable For Investors, But Terms and Conditions Apply.
      ⭐️HURRY NOW!!! Refer a Friend or Family member to invest same time, and Receive an instant $50 Reward. 
      To set up an INVESTMENT PLAN, Contact Admin: totalinvestmentcompany@gmail.com
      WhatsApp: +1(929)390-8581
      View more on YouTube: https://www.youtube.com/channel/UC3KWT9dTpFLi0S0vJTWuCJg

  2. Thanks for the complements on the blog, you should check out the new video clip I added to the post today. I also have a few more I need to edit - one of them has me failing to play the 'fly like a G 5' hook, the synth sound is very close especially for a little 8-bit micro controller - its my attempt at playing it that is not so close.

  3. Great project. I like the "five dollar synth" concept.
    I've made too Illutron and Auduino and some other arduino/audio/midi creations, and try to follow your tutorials. And I was wondering if it was possible (I'm sure you already thought about it) to add some LP, BP or HP filter effects. It seems impossible without FFT analysis, but maybe you have a cheap solution :)
    With multiple waveforms, 2 oscillos (arduino not enough powerful ?), and filters, the five dollars synth would be better than most of 200 dollars synth...

  4. Hi, I Have a few ideas for filters, but I also have a half formed philosophy that the five dollar synth should continue to develop as a low cost machine with a highly configurable sound of its own - rather than try and build in features that any serious musician will already have or that would drive up the cost for any less serious visitors that want to build a machine of their own. Having said that I am looking at using switched capacitor filters and also for software techniques which would provide interesting ways to morph the sound without requiring too much computation. Stay tuned. Duane B

  5. Yes, of course, the filter should have to work on the Arduino Uno. Or maybe some electronic (a few capacitors and resistors should be enough to make a basic LP filter). Maybe you already know, but I found this library which work on the Uno, and have a filter algorithm, but I don't understand at all how it works.

  6. Other idea for synth effects : There's a little effect processor called "biscuit" made by Oto :
    The principle is to create drive or bitcrushing by inverting bits of the digitalized signal (when you push a button on the box, it's inverting a bit). The sound is very crazy and impredictible.
    I think it shouldn't be too difficult to implement an algorithm which inverts bits in an arduino, and shouldn't take too much cpu. And the effect is very original.

  7. Hi,
    I have used bit crushing and another similar effect 'gain' in the five dollar synth. The type of bit crush I have implemented is effectivley down sampling. The other effect, 'gain' is simply digitally multiplying the signal, this causes the output to overflow and wrap around distoring the waveform. I will have a look at the links you have suggested over the holidays.


    Duane B

  8. hi, can you show the entire sketch? thanks so much...

  9. Hi, If anyone wants the code, send me a message with your email address through the arduino forum - www.arduino.cc my username is DuaneB

    Duane B

  10. Hey, I co-run our high school engineering club, and we're starting Arduino stuff right now. What are your thoughts on this project as a beginner project? If not, then what are some good projects you did as a young neophyte?

  11. Hi, I would suggest the Illutron B or the Auduino as good projects to start with -




    Would be interested to hear if your club builds them and happy to post any picture or videos particularly if you come up with some nice enclosures or use interesting sensors instead of the simple potentiometers.

    Duane B

  12. Dear Duane B,
    can you please give some more help for the 4017 scan matrix code?

    Thank you in advance

  13. Dear Duane B,
    I also try to the 5 dollar piano once seen in your blog.
    I finally found a different aproach taken from https://arduinocode.codeplex.com/releases/view/121334

    Thank you for reply and sorry if I annoyed you, but I have seen that I could ask for code if i sent message from arduino.cc

    Thank you and sorry again.

    1. Hello, The link is not working, can you send me the files? :) Thank you so much

  14. Great job. I have a yamaha psr 292 and I intend to do the same with it. But I think it might be trickier becaus its keyboard i s a little bit more complex. Any suggestions?

  15. Can you send me the zip file please, this is great and I want to try it.

  16. Hi Duane. I tried leaving a message at arduino.cc a few days ago (Slider2732), but maybe life moved away from checking there regularly. Got some coding done of the returning signals, plus some MIDI and...now am stuck lol. Would really appreciate the code that you wrote :)

  17. Greetings.
    I sent a message to you from arduino forum. I'm stuck in code :) Thank you so much. :)

  18. Super project!!!
    Thanks for the child keyboard idea..

  19. If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you got to watch this video
    right away...

    (VIDEO) Have your ex CRAWLING back to you...?

  20. Quantum Binary Signals

    Professional trading signals sent to your cell phone daily.

    Follow our signals NOW & make up to 270% a day.

  21. Hey DuaneB.. just revisited this page again to see how far you’ve gotten. You are doing a great job of exposing the value of so called cheap synth chips. A whole EMU chip to run a sound blaster card.... crazy! As an electrical scientist/hobbyist/Synth nut I love the ability to grab sound. I wish Bob Moog was still around, he’d have applauded your creativity. I’ve been working/designing, my SNÖ BEL synthesizer for my company SNÖ SOUND. Here’s something for you to explore. You have an Arduino, You have python libraries... without altering the original keyboard and utilizing all the switches,knobs, and doodads (yes I said that) you can add amazing functionality to your synth with just the cost of time that will be reusable to you in your future endeavors. Take a look at Sonic Pi. I am integrating it into my synth for a truely upgradable synth. I think you might find some answers there. Your comment on software solutions caught my eye. I like how you’re thinking 🤔 sir.

  22. What sort of keyboard is that and where would you get one from?

  23. Thank you for sharing this blog, It is an amazing blog, I am really impressed by your blog, It’s really useful norton.com/setup

  24. Great information, I was searching for this kind of information, thank you very much for sharing with us. i also have some links to share mcafee.com/activate



  25. Very nice blog, I found it very useful .Even I have this wonderful website norton.com/setup


  26. There are many blogs I have read But when I read Your Blogs I have found such useful information, fresh content with such amazing editing everything is superb in your blog, Thank you so much for sharing this useful and informative information with us. Wish you all the best for upcoming comments. And I have also few informative links which I am going share here. wwww.norton.com/setup enter product key
    www.norton.com/setup, Norton product key, Norton com setup download, norton.com/setup

  27. Hi Duane B,
    even if with a few years of delay, I read and appreciated your post "Five Dollar Synthesizer" .... is it possible to have some more information maybe with the zip file that you make available on request?
    Thanks in advance
    best regards
    Pino Barberio (pino.barberio1@gmail.com)

  28. I feel so happy writing this review about the Wizard Charles Group! you can as well hire him today.

    My Credit Card was on the poor side and I couldn’t get a house, a car or even a truck for my new business. I Couldn’t get approved for any type of loan until I read a comment about a private hacker online on how he helped some people fix their credit in the space of 2 Weeks. I gave it a try and reached out to him and to my surprise he came through. He increased Credit score boost to 850 and he also topped up my Credit Balance to $280,000 he did it perfectly well and removed all The negative items I had on my credit,  Notice: If you are looking for a professional hacker to provide hacking solutions on Recovering Scammed funds, increase your Credit score and top up your Credit  to any amount,  Bitcoin Lost funds recovery, Social media hacks  Bitcoin mining, DMV database, Access your spouse/partner social media, Monitor your colleague and a lot more, search no further.  hire them now by  Email: wizardcharles@consultant.com

    WhatsApp: +1 (385) 273 0329

    visit their website to read more about them:  https://wizardcharlesgrouphackers.com/.n/

  29. On this day 10/04/2021, I testify truly about wizardcharles1@gmail.com that indeed they are honest and truly the best to be contracted for any cyber fraud solution mostly when it comes to funds recovering cause I made a huge mistake that almost ruined my life and that of my families whereby both my credit score and funds amounted to $346,000.00 US Dollars were gone simply because I wanted to invest with a broker who made me believe I can become a multimillionaire within 6 months not knowing it was just only a way out to fraud me but all thanks to wizardcharles1@gmail.com

    visit their website to read more about them:  https://wizardcharles1.wixsite.com/mysite/services 

  30. Great project !! But here's something that could be interesting : why not try to make some provision to upload a sound file consisting of the sound required to be played on the pressing of each key and play the sound using the keys ? That may sound a bit hard as you're using an Arduino, but still I guess it will be interesting.

  31. This is an informative blog. Keep it up. I am looking forward to this kind of blog. Thanks for sharing it with us

    buy modalert online

    buy artvigil online

    buy waklert online

    buy modvigil online

    buy vilafinil online

  32. Contact Wizard Larry for problems such as hacking emails, Facebook, Twitter, Instagram, note changes, deleting criminal records, credit and debit refill, reloading insurance documents, lost funds or lost file recovery, background check of people and organizations Monitor your spouse's activities regarding the phone and social media and contact him at Larrywizardhacking57@gmail.com or text him on WhatsApp, telegram(+971551744806) He is trustworthy ��

  33. Wizard Brixton Group of Hacker save My Marriage I was a victim of Marriage cheats from my husband without knowing he has a family outside our Marriage and has been spending my money on them I never know he was capable of such but due thou the recently way he starts sneakily around I got suspicious of him and was in need of a Hacker to spy on him without no doubt my suspicious was true. Wizard Brixton Hacker got me proof of his message and calls and the address of other families where he goes frequently if you have such a cheating partner contact him via Wizardbrixton at Gmail dot com WhatsApp : (+1- /807-23 ) 4-0428 he is a Real Wizard