Picking your brains and experience so i can apply to something i need.
I need to control a VCO using a shift register( lets say a 595).
On the outputs i can control the voltage with a resistive ladder(R2R),DAC style, so in that sense no doubts.
My doubt is this: Would the code below be the best way to have a control of its speed/rate ?! Is there a better, with better response way to do that ?! If so, can you lead me onto the right path, please ?!
Im developing a sound effects box, and despite already having achieved what id set myself to, id love to add more extras, and having a better control over it would be just brilliant to what i need .
//Pin connected to ST_CP of stop
int latchPin = 8;
//Pin connected to SH_CP of stop
int clockPin = 12;
//Pin connected to DS of stop
int dataPin = 11;
int delayInput = 0;
int outDelay =0;
// Out to 74HC595 (Serial TO Parallel OUT)
void stopout(int numberToDisplay)
{
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
// digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, LOW);
digitalWrite(latchPin, HIGH);
}
void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(delayInput, INPUT);
//Lets Clear the LEDs - just incase the 74HC595 'remembers' its last state after restart.
stopout(B00000000);
delay(500);
}
void loop() {
outDelay = analogRead (delayInput);
stopout(B10000000);
delay(outDelay);
stopout(B01000000);
delay(outDelay);
stopout(B00100000);
delay(outDelay);
stopout(B00010000);
delay(outDelay);
stopout(B00001000);
delay(outDelay);
stopout(B00000100);
delay(outDelay);
stopout(B00000010);
delay(outDelay);
stopout(B00000001);
delay(outDelay);
stopout(B00000010);
delay(outDelay);
stopout(B00000100);
delay(outDelay);
stopout(B00001000);
delay(outDelay);
stopout(B00010000);
delay(outDelay);
stopout(B00100000);
delay(outDelay);
stopout(B01000000);
}