Project tutorial
Arduino Step Sequencer

Arduino Step Sequencer © GPL3+

A toy to create "music" or to annoy someone.

  • 250 views
  • 0 comments
  • 1 respect

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

You can find all kinds of super complicated and big sequencers on YouTube and they seem to be fun, so I wanted to try one.

The potentiometers used for the steps are 100K, for a higher resolution. The one for temp and vol are 10K. But these values are not a rule, with a higher resistance we will have a finer adjustment, which is advantageous for the steps.

If the potentiometers change the values in the wrong direction, we can change GND with 5V on the potentiometer or we can change the code ex: "map (analogRead (A0), 0, 1023," to "map (analogRead (A0), 1023, 0,"

To power the arduino I used an old phone battery, a TP4056 module and a dc step up converter. Mounted on the lower level of the toy.

If you use the VIN pin, remember that the diode for reverse polarity protection cuts off 0.7 V.

Code

Arduino sequencerArduino
// Declaration of variables
const byte speaker = 13;  //  Speaker pin
const byte pat0 = 4;      //  Led pins
const byte pat1 = 5;
const byte pat2 = 6;
const byte pat3 = 7;

bool debug = false; // Used to print values to Serial Monitor
bool isOn = false;  // Checks if the device should work or not
long counter = 0;   // Used for speed
long tempo;         // Used for reading the speed
int lowFreq = 10;    // The lower frequency boundary
int highFreq = 2000;// The higher frequency boundary
int pattern = 0;    // Current potentiometer
unsigned int note;  // Note that will be played

void switchLEDs(int pattern) {  // Turn on and off the leds for specific patterns
  switch (pattern) {
    case 0:
      digitalWrite(pat3, LOW);
      digitalWrite(pat0, HIGH);
      break;
    case 1:
      digitalWrite(pat0, LOW);
      digitalWrite(pat1, HIGH);
      break;
    case 2:
      digitalWrite(pat1, LOW);
      digitalWrite(pat2, HIGH);
      break;
    case 3:
      digitalWrite(pat2, LOW);
      digitalWrite(pat3, HIGH);
      break;
  }
}

int getNote(int pattern) {  //  Get notes for specific patterns
  if (pattern == 0) {
    note = map(analogRead(A0), 0, 1023, lowFreq, highFreq);
  } else if (pattern == 1) {
    note = map(analogRead(A1), 0, 1023, lowFreq, highFreq);
  } else if (pattern == 2) {
    note = map(analogRead(A2), 0, 1023, lowFreq, highFreq);
  } else if (pattern == 3) {
    note = map(analogRead(A3), 0, 1023, lowFreq, highFreq);
  }
  return note;
}


void setup() {
  
  pinMode(pat0, OUTPUT);
  pinMode(pat1, OUTPUT);
  pinMode(pat2, OUTPUT);
  pinMode(pat3, OUTPUT);
  digitalWrite(pat0, LOW);
  digitalWrite(pat1, LOW);
  digitalWrite(pat2, LOW);
  digitalWrite(pat3, LOW);
}


void loop() {


  tempo = map(analogRead(A4), 0, 1023, 4000, 100);
  if (tempo < 3900) { // Enter if speed still acceptajk  ble
    if (counter > tempo) {
      if (debug) {
        Serial.println(pattern);
      }
      noTone(speaker);
      counter = 0;

      switchLEDs(pattern);
      note = getNote(pattern);

      pattern = (pattern + 1) % 4;
      if (note > lowFreq + 10) {
        tone(speaker, note);
      }
    }
    counter++;
  } else {  // Stopped on a specific potentiometer
    switchLEDs(pattern);
    unsigned int note = map(analogRead(pattern), 0, 1023, lowFreq, highFreq);
    
    if (note > lowFreq + 10) {
      tone(speaker, note);
    }else{
      noTone(speaker);
    }
  }
}

Schematics

Schematic
Screenshot 3 eam27epv0t

Comments

Similar projects you might like

Egg Step Sequencer

Project tutorial by Patt Vira

  • 3,730 views
  • 5 comments
  • 14 respects

Step Sequencer

Project tutorial by costantinorizzuti

  • 3,877 views
  • 0 comments
  • 9 respects

LED Color Sequencer

Project tutorial by Team thefantasticode.Group

  • 9,589 views
  • 17 comments
  • 32 respects

Interactive Children's Jack-In-The-Box

Project tutorial by Team 10

  • 1,101 views
  • 1 comment
  • 4 respects

20$ RF smart controled RGB LEDS, for bikes

Project tutorial by javier muñoz sáez

  • 3,175 views
  • 0 comments
  • 8 respects

Happy Birthday Melody with Lights and Sounds

Project tutorial by msr048

  • 3,303 views
  • 0 comments
  • 20 respects
Add projectSign up / Login