Hey, I made a little effects (Lo-fi Guitar Pedal)unit that I saw on the instructables.com website from a post by Kyle McDonald.
I made a mono version and the pedal works grand until I try to read the audio signal from analog input 0. As soon as I put in the lines of code necessary to read from the input pin the pedal ceases to work and only emits a continuous hum. Also when I look at the serial monitor it is reading in a continuous stream of values around 504. If I pluck a string on the guitar the values change very slightly. I'm trying to send this data into a Processing sketch.
Here is some of the code with the Serial library lines that I added:
#include "dsp.h"
#include "interface.h"
#define BAUDRATE 9600
#define audioIn 0
#define wait 10
int val = 0;
void setup() {
Serial.begin(BAUDRATE);
pinMode(redPin, OUTPUT); //Sets Pin9 as the red led output
pinMode(greenPin, OUTPUT); //Sets Pin10 as the green led output
pinMode(yellowPin, OUTPUT); //Sets Pin12 as the yellow led output
setupIO(); //calls the setupIO function
}
short prev, originalInput;
void loop() {
updateInterface();
if(delayed > delayLength) {
originalInput = analogRead(left);
short input = originalInput;
switch(mode) {
case bitcrush:
input = input >> value10 << value10;
break;
case bitshift:
input = (input << value10);
break;
case overdrive:
input = (int) (512 + (value20 * (input - 512)));
break;
case binary:
switch(value6) {
case 0: input = input & ~prev; break;
case 1: input = input ^ prev; break;
case 2: input = ~(input | prev); break;
case 3: input = ~(input ^ prev); break;
case 4: input = ~(~input & prev); break;
case 5: input = ~(input & prev); break;
}
break;
}
output(left, input);
output(right, input);
prev = input;
delayed = 0;
}
delayed++;
val = analogRead(audioIn);
Serial.println(val);
delay(wait);
}
void updateInterface() {
if(interfaceUpdate > interfaceSamplerate) {
knoba = analogRead(knobaPin);
knobb = analogRead(knobbPin);
knobc = analogRead(knobcPin);
mode = knoba / modeSpacing; // knoba quantized into mode values
value6 = knobb / 171; // knobb quantized into [0-6]
value10 = knobb / 103; // knobb quantized into [0-9]
value20 = 1 + ((float) knobb / (float) 52); // knobb scaled to [1-20]
delayLength = knobc >> 2;
alternatePin(yellowPin, mode);
digitalWrite(greenPin,
originalInput == 0 ||
originalInput == 1024 ||
(originalInput > 496 && originalInput < 528) ? LOW : HIGH);
switch(mode) {
case bitcrush:
case bitshift:
alternatePin(redPin, value10);
break;
case binary:
alternatePin(redPin, value6);
break;
case overdrive:
digitalWrite(redPin, LOW);
}
interfaceUpdate = 0;
}
interfaceUpdate++;
}
void alternatePin(int pin, int value) {
digitalWrite(pin, value % 2 == 0 ? LOW : HIGH);
}
Sorry if what I'm trying to do doesn't make sense but I'm new to Arduino and also new to writing code.
I would be very grateful if someone could suggest a way to make this work or even if it is possible at all!!
Cheers!