Alright, so this is my first project involving a micro controller, and programming, in which I am using an Arduino Uno to build a step sequencer for a modular synthesizer system. The idea is that it uses pins 2 thru 9 to generate the steps, in which these steps will be brought out to opamps which will be set up as non-inverting amplifiers, which will generate a control voltage that can be varied using a pot on the op amps.
I already have it stepping, however I would like to extend the number of steps beyond 8, and would like to involve the other pins 10-13 to extend the number of steps possibly to 32, and I have uploaded a wiring diagram showing pins 2 and 3, but imagine this extending to pin 9. For the first 8 steps, 10 will be held HIGH (and pins 11-13 LOW) through the AND gates attached to each opamp (not showing the exact wiring; explained above). Once these 8 steps complete, 10 will go low with pins 12 and 13, and 11 will go high, 8 steps later, 12 goes high, so on and so forth, then once 13 is done it will go back to 10. I have no idea how to code this little part.
Here is the code I already have (which was copied and pasted from a sketch made to run single 7 segment displays), all this does is just make the 8 steps, the speed of each step which can be varied with a pot's wiper attached to Analog in 0.
byte sequence[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);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void sequenceWrite(byte digit) {
byte pin = 2;
for (byte seqCount = 0; seqCount < 8; ++seqCount) {
digitalWrite(pin, sequence[digit][seqCount]);
++pin;
}
}
void loop() {
for (byte count = 8; count > 0; --count) {
sensorValue = analogRead(sensorPin);
delay(sensorValue+10);
sequenceWrite(count - 1);
}
}
I'm sure this isn't the really most efficient way to do what I'm doing, but it appears to be simple enough for me to understand, and I've really been wanting to teach myself programming, so I figured this would be a stylish way to do it.