Introduction: Arduino Step Sequencer

About: Im 16 and love electronics! I love music; writing music and playing piano. I have fun with microcontrollers and playing with other stuff too. There's always new things to learn.
I was wondering about on making a sequencer, a big 16 step sequencer was what I wanted to make. To it's full extension with lots of features including single leds for each step, midi input and output, etc. Then I realised that I should start from a more basic model and then maybe tweak around to see what I can do. So while surfing the web and between other small sequencer projects I found this arduino sequencer, named "arduino punk console" after the simple tone output device from the 555 (atari punk console) and using the arduino as the tone generator. 
So here goes a simple project which can later be modified and used in different projects, check last step for more detail on stuff to do with this sequencer. 
Schematic, code and original idea is from Beavis Audio, everything can be found at there website:

Here is a little preview video I made:

Step 1: Materials

The bill of materials to making this project consists in:
  •  X8 Momentary pushbuttons, normally open.
  •  X1 Small Toggle DPDT switch.
  •  X1 LED, whichever color, it's only used to indicate that the Arduino is on and working.
  •  X9 10K resistors.
  •  X4 100K Potentiometers.
  •  X1 Female stereo jack, it can be 3,5mm or a 6,3mm. 
  •  X1 Cable.
  •  X1 Enclosure, I just picked up a simple hard plastic box.
  •  X4 Knobs for the pots, only if you wish so.

List of tools to elaborate:
  •  Soldering Iron.
  •  Solder.
  •  Drill.
  •  Tweezers.
  •  Screwdrivers.

Step 2: Schematic and Wiring

Following the schematic is fairly easy. What we must notice is that the 10K resistors are pull down, this means it's hooked up to ground and it holds the logic signal when no other active device is connected. So you must hook the wire leading to the Arduino pins for the steps from the pushbutton. Arduino pins from digital 10 till 2 go to pushbuttons.
Then connect all buttons together with the pots positive lead and hook it up to 5V. All Resistors go together with pots negative leads and hook it up to ground. Also notice the traditional 100K wiring for the volume, which goes to Arduino digital 11. The pots go hooked up to Arduino analog 0, 1 and 3. Finally a red led goes to Arduino pin digital 12. 

*There are two schematics. One that I made on Fritzing and the second one which is much better organised, can be found at beavis audio.

Step 3: Code

The original code comes with a LCD setup for displaying frequency changes. I just deleted that part, but you can get the code with lcd setup here.

/* ======================================================================
Arduino Punk Console
A simple programmable 8 step tone sequencer
by dano/
15 Sept  djh  initial version
// Map all the input and output pins
#define AnalogInFrequency 1
#define AnalogInTempo 2
#define AnalogInDuration 0
#define DigitalOutSignal 11
#define DigitalInSwitch0 2
#define DigitalInSwitch1 3
#define DigitalInSwitch2 4
#define DigitalInSwitch3 5
#define DigitalInSwitch4 6
#define DigitalInSwitch5 7
#define DigitalInSwitch6 8
#define DigitalInSwitch7 9
#define DigitalInStartStop 10
#define DigitalOutLED 12
// Set up the array for each step
int steps[] = {100,120,140,160,180,200,220,240};
// misc housekeeping
int duration = 50;
int pitchval = 1;
int fPlayMode = true;
int lastPushedStep = -1;
// Initialize the tempo
int tempo = 100;
void setup()
  // setup pin modes (Digital pins are input by default, but
  // I like to set 'em explicitly just so the code is clear.
  pinMode (DigitalInSwitch0, INPUT);
  pinMode (DigitalInSwitch1, INPUT);
  pinMode (DigitalInSwitch2, INPUT);
  pinMode (DigitalInSwitch3, INPUT);
  pinMode (DigitalInSwitch4, INPUT);
  pinMode (DigitalInSwitch5, INPUT);
  pinMode (DigitalInSwitch6, INPUT);
  pinMode (DigitalInSwitch7, INPUT);               
  pinMode (DigitalInStartStop, INPUT);
  pinMode (DigitalOutSignal, OUTPUT); 
  pinMode (DigitalOutLED, OUTPUT);


void loop()
  // Main sequence loop 
  for (int i=0; i<8; i++)
    // Are we playing or stopping?
    fPlayMode = digitalRead (DigitalInStartStop);
    digitalWrite (DigitalOutLED, HIGH);
    // Check the Hardware

    // update the display

    // Make the noise
    if (fPlayMode)
      freqout (steps[i], duration);
    digitalWrite (DigitalOutLED, LOW);

    // Pause between steps
    delay (tempo);      

void updateDisplay()
  Serial.print (254, BYTE);
  Serial.print (192, BYTE);
  Serial.print ("T:");
  Serial.print (tempo);
  Serial.print (" d:");
  Serial.print (duration);
if (lastPushedStep != -1)
    Serial.print ("*");
    Serial.print (lastPushedStep);
// Read the current values of the pots, called from the loop.
void readPots ()
    tempo = (analogRead (AnalogInTempo) * 1.9);
    duration = (analogRead (AnalogInDuration));     
// Read the current values of the switches and
// if pressed, replace the switch's slot frequency
// by reading the frequency pot.
void readSwitches()
  // reset last pushed button number
  lastPushedStep = -1;

  // check switch 0, if pressed, get the current freq into step 0, etc. etc.
  if (digitalRead (DigitalInSwitch0) == HIGH)
    steps[0] = analogRead(AnalogInFrequency);
    lastPushedStep = 1;

  else if (digitalRead (DigitalInSwitch1) == HIGH)
    steps[1] = analogRead(AnalogInFrequency);
    lastPushedStep = 2;

  else if (digitalRead (DigitalInSwitch2) == HIGH)
    steps[2] = analogRead(AnalogInFrequency);
    lastPushedStep = 3;
  else if (digitalRead (DigitalInSwitch3) == HIGH)
    steps[3] = analogRead(AnalogInFrequency);
    lastPushedStep = 4;
  else if (digitalRead (DigitalInSwitch4) == HIGH)
    steps[4] = analogRead(AnalogInFrequency);
    lastPushedStep = 5;
  else if (digitalRead (DigitalInSwitch5) == HIGH)
    steps[5] = analogRead(AnalogInFrequency);
    lastPushedStep = 6;
  else if (digitalRead (DigitalInSwitch6) == HIGH)
    steps[6] = analogRead(AnalogInFrequency);
    lastPushedStep = 7;
  else if (digitalRead (DigitalInSwitch7) == HIGH)
    steps[7] = analogRead(AnalogInFrequency);
    lastPushedStep = 8;

//freqout code by Paul Badger
// freq - frequency value
// t - time duration of tone
void freqout(int freq, int t)
  int hperiod;     //calculate 1/2 period in us
  long cycles, i;

  // subtract 7 us to make up for digitalWrite overhead - determined empirically
  hperiod = (500000 / ((freq - 7) * pitchval));            

  // calculate cycles
  cycles = ((long)freq * (long)t) / 1000;    // calculate cycles
  for (i=0; i<= cycles; i++)
  {              // play note for t ms 
    digitalWrite(DigitalOutSignal, HIGH); 
    digitalWrite(DigitalOutSignal, LOW); 
    delayMicroseconds(hperiod - 1);     // - 1 to make up for fractional microsecond in digitaWrite overhead

Step 4: Enclosure

Making holes is very simple but sometimes can be very tedious, especially when theres many holes. I took out a ruler a divided the box into 8, so I could drill 8 holes. After that, above I drilled two holes for the pause switch and the LED. Above 4 Holes for the pots. On the side a hole for the output and beneath a square for the Arduino usb port, so you can feed power through it. After putting everything in there place I slided in some Knobs on the pots and screwed ever component to the plastic box.
To making holes; try all type of drill bits to see what fits better for each component.

Step 5: Wrapping Up

So it's a fun piece of machine, and I wanted to share this nice build so later you can modify it and eventually make something even better. A few ideas on improvement would be; having a led for each step, that you could hold a tone to change it's frequency, have an input so you can send synth based sounds into this little machine, and finally add a MIDI output for using with the computer.
For know, Im going to use some sound effect boxes, which have input and output, so I can listen to the kind off sound generated with the steps.
*All credit goes to beavis audio; who made this project and also wrote the Arduino sketch.


Instructables Design Competition

Participated in the
Instructables Design Competition

Holiday Gifts Contest

Participated in the
Holiday Gifts Contest