Step 1: Set Up Arduino
I used both analog pins as outputs, so set pins 5 and 9 as outputs in Arduino. I set up Serial.begin so that I could print any incoming values while troubleshooting.
Step 2: Set Up Variables
The only variable I used in this code was for the fader, which controlled the tone of the oscillator (by altering the mix of Arduino's voltage output with that of the oscillator) and the brightness of the lights. The fader was coming into analog input 1, so I created the variable "PotVal" to equal "analogRead(A1)". Because the oscillator and lights read a different scale than the fader outputs, I used the "map" function to create a "scaledPotVal" as well.
Step 3: Set Initial Voltages
In order for Arduino to output audio signal it needs to write a voltage. When the synth is turned on, the micro-sequencer should be silent and the oscillator should match the tone of the fader. So the initial voltage to pin 5 (micro-sequencer) should be 0 and the initial voltage of pin 9 (oscillator and lights) should be the "scaledPotVal".
Step 4: Activate Button
To make the button turn the micro-sequencer on and off, it has to act like a switch. I used the latch bit to create this effect. In an analog setting, the button reads 1023 when it is "on" (HIGH) and 0 when it is "off". I created an if/else that sent a voltage of 37 to pin 5 if analog input 1 read 1023 and sent 0 voltage to pin 5 if else.
Step 5: Add Effects
To make the melody aspect of the synth more customizable, I added filter and delay to the oscillator. The cut off of the filter seemed to have the biggest impact on the effect of the fader.
Step 6: Lights
To make the effect of the fader more obvious, I used a splitter bit to connect lights to pin 9, the same pin as the oscillator. This means that the lights are also reading the "scaledPotVal", which affects the brightness rather than the tone of the lights.