Go Down

Topic: TMRpcm, Mega2560, Duo Speakers give static (Read 769 times) previous topic - next topic


Nov 07, 2018, 05:25 pm Last Edit: Nov 07, 2018, 05:43 pm by SashaD
Using Mega 2560, W5100 Ethernet Shield, SD card and 2 speakers. When I connect 1 speaker, the sound plays fine. However, the speaker has to be in pin 12, pin 11 is just static. When 2 are connected, I hear just static, but static from both speakers. I put one speaker into pin 11 and the other in pin 12, the output.
Edit: english is hard. The correct pin to use was 46-45
Code: [Select]

#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>

#define SD_ChipSelectPin 53  //example uses hardware SS pin 53 on Mega2560
//#define SD_ChipSelectPin 4  //using digital pin 4 on arduino nano 328, can use other pins

TMRpcm audio;   // create an object for use in this sketch

void setup() {
  audio.speakerPin = 11; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
  pinMode(12,OUTPUT);  //Pin pairs: 9,10 Mega: 5-2,6-7,11-12,46-45
  if (!SD.begin(SD_ChipSelectPin)) { 
    Serial.println("SD OK");

void loop() {


I uncommented #define STEREO_OR_16BIT as the library says to do. I left #define buffSize 128 because the library says I shouldn't with a MEGA board. Also, both speakers are connected to their own GND. Also pin 11 is fine, when i set output to 10, 11 alone works fine


When 2 are connected,
Never connect outputs directly together, that is a great way to burn out a pin.

You have a Mega yes? Then why have you still got this line in your code?
Code: [Select]
audio.speakerPin = 11; //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
Should the speaker piin not be set to 46 like it says in the comment?


Nov 07, 2018, 05:40 pm Last Edit: Nov 07, 2018, 05:49 pm by SashaD
Edit, sorry my english is not my strong suit, i thought it meant Mega can use 11 or 46. I just spent alot of time trying to make it work with 11 thinking 11 works with mega fine due to the fact that a single speaker worked fine on it. I will not directly connect the speaker to the arduino anymore. Luckily, none of the pins burnt out yet( i think), thanks for telling me so. I am worried about the sound getting quieter though


Nov 08, 2018, 07:13 am Last Edit: Nov 08, 2018, 07:13 am by Lucario448
I am worried about the sound getting quieter though
Using low-impedance speakers? If yes, then no wonder why you're having voltage (loudness) drops. In those cases, an amplifier is mandatory.

If not, then it might be a supply voltage drop (overloading the 5V pin?).


A hack I tend to use for class-D audio is to use a pair of low-side MOSFET driver chips to boost
anti-phase class-D logic signals to high current.

Its not ideal, the output resistance is higher than you would want, and heat sinking SOIC packages isn't
very efficient, but it seems to work.

Note that MOSFET drivers need 5V supply or more, 3.3V isn't going to be enough.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up