Arduino Tone Step Sequencer

I’ve been meaning to build a step sequencer for a while.  This is device that you can use to repeat a simple sequence of notes over and over and build up interesting patterns.

  • In the next part I’ll be adding MIDI out.

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.

Parts list

  • Arduino Uno or Nano
  • 8 ohm speaker or old headphone speaker
  • 1x 220Ω resistor
  • 6x or 8x 10k potentiometers
  • Breadboard and jumper wires

The Circuit

ArduinoToneStepSequencer_bb

This circuit hooks up a potentiometer to each of the Arduino’s analog inputs. If using an Arduino Nano there are eight analog input (A0 to A7) that can be used.  If using an Uno there are six.  Each potentiometer is connected across 5V and GND with the wiper pin connected to the Arduino’s input.

Note that in the diagram I’ve not fully connected up the bottom row of potentiometers as it would obscure the wiring, but all four need to be connected up as shown in the fourth one.

A speaker is connected, via a 220Ω resistor to digital output pin 9 for use with the tone() function.

In the video you can see an Arduino Nano linked to eight pots on a solderless breadboard and an Arduino Uno linked to my six-pot board made for the Arduino Multi-pot Mozzi FM Synthesis project.

The Code

This is essentially the same code used in the Arduino Note Generator but instead of playing a single note there is a general loop going on as follows:

For each potentiometer
   Read the potentiometer value
   Use the value to determine a note to play using tone()
   Pause for a while before reading the next potentiometer

If at any point the potentiometer is set to zero then the notone() function is called to turn off the sound for that “note.

If there are eight potentiometers then an eight note sequence is possible.  For six, then six notes are played.  The notes to be played can be changed “on the fly” simply by adjusting the potentiometers and the note sequence will repeat endlessly with a fixed delay between each note.

I set the delay to 250 uS which means there are four notes played every second.

Sometimes the reading from the pot might drift a little.  For this reason, I consider “off” as being “any value less than 4 read from the pot”.  It also means that occasionally a pot setting might cause the sequence to alternate between two adjacent notes.  I could possibly fix this with more accurate scaling between potentiometer readings and notes (there are 1024 levels possible from the pot, but only around 90 notes to choose from), but actually I quite like it.

Find it on GitHub here.

Closing Thoughts

I really like the contrasting “in three” and “in four” feels of having six or eight notes in the sequence.  Some next steps I’m considering include:

  • Defining a fixed scale of notes – maybe only notes from the pentatonic scale or notes within a certain mode.
  • Adding MIDI out so it will generate MIDI notes rather than using the built-in tone() function.
  • Using a button to select a different number of notes in the sequence, up to the maximum supported by the Arduino being used (six or eight).
  • Adding some rhythm by way of adding support for an Arduino MIDI Relay Servo Drumkit.
  • Adding some means of changing the tempo.
  • Synchronising the sequence to an external trigger.

Kevin

Leave a comment