Having now plugged an Arduino into my Toy Keyboard, it is time to start experimenting.  The first thing I really wanted to do, was build an Oskitone Scout, but not having a 3D printer or the funds to purchase one, I thought I'd have a go at getting the code to run on my toy keyboard.  Here is the result.

  • Consult Part 1 for details of adding an Arduino to the original toy keyboard.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

The Oskitone Scout

Oskitone produce small keyboards and mini-synths in full, kit, or "build it yourself" forms, that have a very unique charm.  All of the designs for the cases, electronics and code have been published on GitHub, which makes them very DIY-friendly.

Some of my tone and "top octave generator" experiments were inspired by the Poly555.

This latest experiment is inspired by the Scout Synth, which is a 1.5 octave, 3D printed, Arduino-based, hackable "synth".  In its default form it uses the Arduino tone() output, but has a really interesting portamento (gliding) effect as it is played.

The DIY Toy Keyboard Scout

I was really keen to see what would be involved in getting the Scout code running on my toy keyboard.  It turns out, not a lot!

The scout code can be found on GitHub here: https://github.com/oskitone/scout/tree/main/arduino/scout

It relies on the following two libraries:

  • Arduino KeyPad (the same one I've used myself) - this comes with the Arduino environment.
  • CircularBuffer (by AgileWare").  This is available via the Arduino Library Manager.  Note there is a CircularBuffer implementation that comes with the Mozzi library but that is not compatible with this code (as I found out when it all failed to build!).

The following changes are required to the Scout code to make it work with my Toy Keyboard.

Notes.h

Change the NOTES_COUNT to 32 rather than the Scout's 17.

const int NOTES_COUNT = 32;

KeyBuffer.Cpp

As the Scout uses the same KeyPad library as my previous code, it is simply a case of replacing the Scout's key matrix with that of my own toy keyboard.  Note that I've only decoded the actual music keys here.  Also, the values representing keys need to be consecutive numbers starting from 1, not the MIDI note numbers that I used last time.  Recall that my keyboard has a weird numbering sequence!

const byte ROWS = 8; const byte COLS = 4; char key_indexes[ROWS][COLS] = { /*        BP07  11  12  13 */ /* BP20 */ {32, 24,  9,  1}, /* BP21 */ {31, 23, 10,  2}, /* BP22 */ {30, 22, 11,  3}, /* BP23 */ {29, 21, 12,  4}, /* BP24 */ {28, 20, 13,  5}, /* BP25 */ {27, 19, 14,  6}, /* BP26 */ {26, 18, 15,  7}, /* BP27 */ {25, 17, 16,  8}, }; //                  BP20,21,22,23,24,25,26,27 byte rowPins[ROWS] = { 4, 5, 6, 7, 8,10,11,12 }; //                 BP07,11,12,13 byte colPins[COLS] = {1, 0, 2, 3};

Scout.ino

Finally there are a couple of changes required to the main Scout file as follows.

There is a change relating to the number of keys (it needs to know how many keys are on the keyboard below "concert A" in order to calculate the correct frequencies), and the pin for the tone/speaker output needs changing.

const int STARTING_NOTE_DISTANCE_FROM_MIDDLE_A = -16; const int SPEAKER_PIN = 9;

The code uses digitalWrite to the LED_BUILTIN as an indicator, but you may recall that for my toy keyboard, the sense of the LEDs are reversed.  Consequently, I have to change

digitalWrite (LED_BUILTIN, HIGH)

to

digitalWrite (LED_BUILTIN, LOW)

and vice versa.

If I was being good, I'd probably turn these into ledOn() and ledOff() functions as I've done before to keep the specific logic away from the main code, but this will do for playing around.

Finally, as I'm using RX/TX to decode the keyboard, I've also disabled the Serial.print functionality.  Although as I'm not using all the buttons, I could move the appropriate "column" connections over to some different digital pins, but I've opted to keep the same pinout as before for now.

This involves commenting out the following:

In setup(): // Serial.begin(9600);  In loop():   if (printToSerial) {     //frequency.print();   }

Although to be honest, as long as printToSerial is set to false, these could probably be left in with no side effects as the serial port won't be used anyway.

And that is it.  Build and upload and my toy keyboard is not an extended, DIY Oskitone Scout!  But without the charm 🙂

Closing Thoughts

This was surprisingly easy to do - I really wasn't expecting that, but I was just so attracted to that characteristic Scout glide that I had to give it a go.  And I think it has ported over really well!

I do need to get some control of volume in there though.  The original had digital VOL+ and VOL- controls, but I'm wondering about adding an actual analog volume pot into the output.

Alternatively, I might use the slider on/off switch as a simple passive HIGH/LOW volume control...

Kevin

IMG_5827


This free site is ad-supported. Learn more