Hi! I'm stumped and wondering if anyone here might have a suggestion for me to try.
I'm using an Arduino Nano Every to sense the position of a Stacked-DPST 3-way pickup selector toggle in a guitar. Selection of a pickup energizes a relay coil from Arduino D2 or D4, causing the signal path from the selected pickup to be connected directly to the guitar output - a 1/4" TRS Female jack. My poorly written code is working as desired, but I'm getting some unexpected behavior that I can't figure out how to solve. The Arduino isn't connected to signal...only power.
Unexpected Behavior 1: Audible ~500 Hz square wave sound being introduced into the signal path (there seem to be harmonics present). When I turn off the Main power, wait 5 seconds, turn-on the Main power - the noise is gone. Ideas/Suggestions to not have to power-cycle to not get noise induced into the output?
Unexpected Behavior 2: When selecting the P90 with the Toggle switch, the audio will cut out for around 1 second and then fade in. This seems to happen after I've been playing using the Humbucker for 1-2min, and then switch to the P90 using the Toggle. When I switch back/forth rapidly, no problem.
I appreciate any help/suggestions ![]()
Code below & Wiring Schematic Attached
Tommy
//Hardware involved (*qty 1 assumed unless otherwise noted):
//Arduino Nano Every
//3-Way Toggle - Stacked DPST
//P90 Single Coil Pickup
//Humbucker (Dual Coil) Pickup
//(3)LED SPDT Latching On/Off Buttons
//Rechargeable 9V Battery w/micro USB Charging Input from Ring contact of TRS. Audio Output to Tip...just the tip
//(2)DPDT 5v Relays
//TRS 1/4" Female Jack
//Toggle Switch Operation:
//Position 1 - P90 Selected
//Position 2 - Both Selected (Center)
//Position 3 - Humbucker Selected
void setup() {
pinMode(7, INPUT_PULLUP);//Position 1 - P90 Selected
pinMode(8, INPUT_PULLUP);//Position 3 - Humbucker Selected
pinMode(2, OUTPUT);//To P90 Relay Coil
pinMode(4, OUTPUT);//To Humbucker Relay Coil
//unused pins to ground
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A5, INPUT_PULLUP);
}
void loop() {
int sensorVal1 = digitalRead(7);
int sensorVal2 = digitalRead(8);
if (sensorVal1 == HIGH) {
digitalWrite(4, LOW);
} else {
digitalWrite(4, HIGH);
}
if (sensorVal2 == HIGH) {
digitalWrite(2, LOW);
} else {
digitalWrite(2, HIGH);
}
}
Guitar 2 wiring - dual dpdt relay and arduino_schem.pdf (847 KB)