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?