Code dump, if you want/need it:
//I/O
const int FADER1 = A0;
const int FADER2 = A1;
const int FADER3 = A2;
const int FADER4 = A3;
const int FEEDBACK = A4;
const int PITCH_SLIDER = A5;
const int AUDIO_OUT = 11;
//global variables
int pitchAfterSlider = 0;
int feedbackAmount = 0;
float outputVoltage = 0;
void setup() {
// Serial Initialisation
Serial.begin(9600);
//Don't know, don't care, don't touch
TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM20);
TCCR2B = _BV(WGM22) | _BV(CS22);
OCR2A = 1;
}
void loop() {
// Call my functions.
pitchStuff();
faderOscillator();
feedbackStuff();
//Serial printLine
Serial.println(analogRead(FEEDBACK));
//pitchAfterSlider = 255;
}
//Does some things. Maps feedback to 8-bit int, adds some of the output back in, then slaps it on pitch
void feedbackStuff() {
feedbackAmount = map(FEEDBACK, 0, 1023, 0, 255);
//feedbackAmount += (outputVoltage);
OCR2A += (1/feedbackAmount) * outputVoltage;
}
//Don't even know if the Slider works, but this should do pitch things.
void pitchStuff() {
pitchAfterSlider = map(analogRead(PITCH_SLIDER), 300, 800, 1, 255);
pitchAfterSlider += 10;
if (pitchAfterSlider > 0) {
OCR2A = pitchAfterSlider;
}
//UNNEEDED
//Serial.println(analogRead(PITCH_SLIDER));
//delay(pitchAfterSlider/100);
}
//4 step Sequencer
void faderOscillator() {
outputVoltage = map(analogRead(FADER1), 0, 1023, 255, 0);
analogWrite(AUDIO_OUT, outputVoltage);
delay(1);
outputVoltage = map(analogRead(FADER2), 0, 1023, 255, 0);
analogWrite(AUDIO_OUT, outputVoltage);
delay(1);
outputVoltage = map(analogRead(FADER3), 0, 1023, 255, 0);
analogWrite(AUDIO_OUT, outputVoltage);
delay(1);
outputVoltage = map(analogRead(FADER4), 0, 1023, 255, 0);
analogWrite(AUDIO_OUT, outputVoltage);
delay(1);
}