-
B8dddc6c 80fe 418a b258 9de47c7c23e6

invention

Dual Tone Auto Piano (#NationOfMakers Challenge #2)

by katharos

Published on June 27, 2016

Using an arduino bit we made a piano that plays a song using only one button.
It can play two notes at the same time, the melody line and an independent arpeggiated bass line where the chord transitions are synchronized with the melody.
There is one input button that advances the melody, and a knob that lets you control the speed of the bass line.
The melody and bass line are programmed into the arduino sketch, and I tried to make them easy to change to whatever you want.
In retrospect, if I had to start over again, I would ditch the Tone library, and try using the arduino to output an analog value which I would input into an oscillator bit.  It would probably sound much better than attempting to do the synthesis directly onboard the arduino.  It might be a little bit more fiddly getting the tuning right though, possibly the a-to-d doesn't have enough resolution, but I'd like to experiment with it some time.

Duration: A couple days worth of debugging arduino hardware timers. (Time to recreate given debugged code, 15min)

Credits: Rebecca & Penelope

How To Make It

STEP 1 : Install Tone Library

Download and install the Tone library from https://code.google.com/archive/p/rogue-code/wikis/ToneLibraryDocumentation.wiki This library is abandoned and hasn't been upgraded for the Leonardo board, which is basically the LittleBits board, so you need to download and replace Tone.cpp with the attachment in the third to last message from this page: https://github.com/gugiar/rogue-code/issues/13 Once you do that you should be able to play 2 simultaneous tones. If you want you can play 3, but that will take over the timer also used for delay() and millis() functions: if you try to use those functions while playing 3 notes your code will hang.

STEP 2 : Build the circuit

Following the picture, on the left side of the arduino bit hook up a dimmer, or other variable source, and a button, with power going to each of them. (BitSnap, splitter, whatever.) On the right side, the top pin goes to the trigger pin of an envelope, the middle pin is the bass line, which goes directly to a mix bit, and the bottom (melody) pin goes to the input of the envelope. The output of the envelope goes to the second mix input. Hook the mix up to a filter to help with the popping you get from arduino synth, and snap a synth speaker onto the end.

STEP 3 : Load code onto the arduino bit

Copy the code from this page and paste it into a new sketch. Use the arduino cable to upload auto_piano.ino, and then tune envelope, mix and filter knobs to taste.

STEP 4 : Write your own music

Right now my code is set up to play 'This Pretty Planet'. To change it to anything you like, just change the notes declared in melody[] and the chords declared in bass[], the notes in melody should match up 1-to-1 with the bass chords. The code will auto detect the length of the array, but they need to be the same. You can also change which notes are defined in notes[] (which will of course change which numbers you use in melody[], since melody[] is just an index into notes[], and you can also change the chords, which are set up in chords[] using any of the notes defined in Tone.h.

Related Projects

Hans Solo #BitWars

Big Hans Solo that shoots!

#BitOlympics Ski Lift Line Speed Indicator & Tower Lights

The Ski Lift is a staple of downhill skiing. Without them, it would be a lot harder to ski or snowboard some of the most beautiful...

Windmill

Lego and littlebits windmill.