Arduino Nano in my Guitar induces noise until power cycle

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 :slight_smile:

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)

I'm a little confused about the schematic. Is the pickup connected to D8 & D9? That can be a problem when the Arduino isn't powered, and/or if the signal goes negative by more than about 1/2V the Arduino's protection diodes will kick-an and cause clipping/distortion (on the negative half of the wave).

And battery power goes-through the TRS jack? ...That might be OK if the DC is "clean" but the power will make contact with the audio-side of the plug as you plug it in-and-out.

...As you know guitar pickups and their high impedance connections are very sensitive to noise, and as you may not know digital electronics are (electrically) noisy!

Just in general, building audio circuits is tricky because of noise. (That's the sensitivity or our ears.) Having digital electronics "nearby" or connected makes it trickier.

Relays are usually fine for this kind of thing but you might have to put some physical distance between the guitar signal and the digital stuff. (Hopefully I'm wrong and there is no connection between the pickup and the Arduino.)

A few things to consider ...

  • The outputs of the Arduino Nano Every (20 mA max) can't be used to energize a relay coil which would require much higher current. Let's assume you're using an ultra-sensitive G5V-2-H1 ... this relay requires 30 mA.

  • Each relay coil needs a transistor (or MOSFET) to energize the coil by connecting to GND (low-side switch).

  • Each relay coil needs a flyback diode.

Hey Doug!

You'll be glad to know that signal isn't being passed through the Arduino. I did a b-hole load of research and opted against building that circuit right now. Instead, I'm using a dang microprocessor to essentially make an LED light-up when I select a pickup. I had this working with 4 relays and no Arduino, but I like to make things difficult on myself apparently. lol

The 3-way toggle switch is connected to D7 & D8 - Nothing connected to D9 :slight_smile:

Pickups are connected to Common of their corresponding relays.

Battery charging input goes through just the Ring contact of the TRS jack. Ring & Sleeve are shorted when plugged-in using a mono 1/4" cable. It's only "active" when i'm using it as an Input to charge the battery. - I used a 1/4" TRS cable, cut it, and soldered the Ring & Sleeve to a USB connector. Then I plug that into the wall adapter and charge :slight_smile:

Are the audio grounds connected to the Nano ground?

Yep!

Thank you for this!!! :metal:

could that be the cause of the unexpected behaviors i'm seeing?

i have a dual optocoupler relay module i can swap back in. it has a 5mA trigger so, yaaay :raised_hands:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.