Author Topic: Arduino Step Sequencer tweaking  (Read 1855 times)

0 Members and 1 Guest are viewing this topic.

Offline proschunoTopic starter

  • Contributor
  • Posts: 20
  • Country: us
Arduino Step Sequencer tweaking
« on: April 24, 2014, 12:54:34 am »
My goal is to try and build a basic step sequencer for synthesizers that generates a series of control voltages in a timed sequence. The heart of this is an Arduino I'm using, which involves turning one output pin at a time, leaving the others of, such that the pulses form a traveling sequence. The speed of each  pulse is controlled by a pot's wiper connected to the Analog pin 1. The steps start from pin 9 and go to pin 2

A problem I'm having is that when I adjust it in large increments, the Arduino will usually stick in the previous speed, and it will take a little while to change its beat. Here is the coding for it:

byte seven_seg_digits[8][8] = { { 1,0,0,0,0,0,0,0 },  // = 0
                                                           { 0,1,0,0,0,0,0,0 },  // = 1
                                                           { 0,0,1,0,0,0,0,0 },  // = 2
                                                           { 0,0,0,1,0,0,0,0 },  // = 3
                                                           { 0,0,0,0,1,0,0,0 },  // = 4
                                                           { 0,0,0,0,0,1,0,0 },  // = 5
                                                           { 0,0,0,0,0,0,1,0 },  // = 6
                                                           { 0,0,0,0,0,0,0,1 },  // = 7
                                                             // = 9
                                                           };


int sensorValue = 0;
int sensorPin= A0;

void setup() {               
  pinMode(2, OUTPUT);   
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);

}

   
void sevenSegWrite(byte digit) {
  byte pin = 2;
  for (byte segCount = 0; segCount < 8; ++segCount) {
    digitalWrite(pin, seven_seg_digits[digit][segCount]);
    ++pin;
  }
}

void loop() {
  sensorValue = analogRead(sensorPin);
  for (byte count = 8; count > 0; --count) {
   delay(sensorValue+5);
   sevenSegWrite(count - 1);
  }

}


I just copied this off another program designed to run single 7 segment displays, and just adjusted it a little bit until I got it to do what I wanted. However, what exactly should I do to get it to respond more readily to changes in the input analog voltage?

And last, this is my real first Arduino project, so I have hardly any idea how to program, but could someone explain to me how the after the "Void sevensegwrite" part of the code works?

« Last Edit: April 24, 2014, 01:37:56 am by proschuno »
 

Offline Hideki

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: no
Re: Arduino Step Sequencer tweaking
« Reply #1 on: April 24, 2014, 01:45:20 am »
Move analogRead inside the loop. Right now you're only checking the pot once at the beginning of the sequence, so it doesn't matter how much you turn it while it's in the middle of it - the speed will only be updated at the start.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf