# Musical Step Sequencer

My goal is to make a 16 step sequencer for controlling a synthesizer with a 0-5 volt control voltage input. The physical device will have 16 potentiometers (to meter down the 5v digital output of each individual step in the sequence). There will also be 16 momentary pushbuttons, one with each potentiometer.

For example: If I push buttons 1 and 16 (corresponding to steps 1 and 16), the sequence will loop from 1 to 16 and repeat indefinitely until another random 2-button combination is pressed. Note: this needs to work with momentary pushbuttons.

I'm somewhat inexperienced with coding, so I'm just looking for advice to approach this so that the final code isn't 10 miles long, considering there are 136 sequence possibilities. Planning on using an Arduino Mega because of the need for 16 digital ouputs (ouput voltages from individual steps) and 16 digital inputs (pushbuttons)... plus a few analog inputs to control the tempo.

What will you use as your raw source to "sequence" ?

KenF: What will you use as your raw source to "sequence" ?

It's just sequencing digital outputs from the Arduino. There will be 16 digital output pins which output the standard 5 volts (only one of the 16 outputs will be on at a time). The 5 volt outputs from these pins will be regulated down (0-5v) using the 16 potentiometers.

The coding needs could be simplified if I explain it as a 16-step LED sequencer, illuminating one LED at a time, where the start and end of the sequence can be changed. Pressing 2 buttons at the same time needs to set the corresponding steps as the start and end of the looping sequence.

``````int pots[8]={A0,A1,A2,A3,A4,A5,A6,A7};
int pans[8]={53,51,49,47,45,53,51,49};//button inputs

int potValues[8]={0,0,0,0,0,0,0,0};

void setup()
{
int n;
for(n=0;n<8;n++)
pinMode(pans[n],INPUT_PULLUP);
}

//used to hold range
int rangeStart=0;
int rangeEnd=0;

void loop()
{
int buttonsDown=0;
int currentFirst=0;
int currentLast=0;

int n;
//first get values of all the pots
for(n=0;n<8;n++)

//now check which buttons are being held
for(n=0;n<8;n++)
{
{
if (buttonsDown>0)
currentLast=n;
else
currentFirst=n;
buttonsDown++;
}
}

//Only update the global variables if at least two buttons are currently down
if(buttonsDown>1)
{
rangeStart=currentFirst;
rangeEnd=currentLast;
}
//So now we have all the values for the pots in PotValues
//We have the rangeStart and rangeEnd in global variables
//But I haven't a clue what you want to do with it.
}
``````

Ken,

Thanks for the help. However, I intended the potentiometers to merely regulate the output of the 5v digital pins. The potentiometers are not actual analog inputs to the arduino.

I just need the basic sequence to go note1 == HIGH note1 == LOW note2 == HIGH note2 == LOW note3 == HIGH note3 == LOW note4 == HIGH note4 == LOW all the way to note 16, then repeat

The hard part is making the beginning and end of the loop variable.

Then simply remove the parts that you don’t need Like so

``````//REDUNDANT
//int pots[8]={A0,A1,A2,A3,A4,A5,A6,A7};

int pans[8]={53,51,49,47,45,53,51,49};//button inputs

//REDUNDANT
//int potValues[8]={0,0,0,0,0,0,0,0};

void setup()
{
int n;
for(n=0;n<8;n++)
pinMode(pans[n],INPUT_PULLUP);
}

//used to hold range
int rangeStart=0;
int rangeEnd=0;

void loop()
{
int buttonsDown=0;
int currentFirst=0;
int currentLast=0;
int n;

//THIS SECTION IS REDUNDANT AND CAN BE REMOVED
/*
//first get values of all the pots
for(n=0;n<8;n++)

*/

//now check which buttons are being held
for(n=0;n<8;n++)
{
{
if (buttonsDown>0)
currentLast=n;
else
currentFirst=n;
buttonsDown++;
}
}

//Only update the global variables if at least two buttons are currently down
if(buttonsDown>1)
{
rangeStart=currentFirst;
rangeEnd=currentLast;
}

//So now we DON'T have any values for the pots
//We have the rangeStart and rangeEnd in global variables
//still don't know what you want to do with it
}
``````