How to Play an Audio using Arduino Uno

I'm using a 8 ohms 1 watt speaker, MicroSD card adapter, and SD card

here is one of the code I used

#include "SD.h"
#define SD_ChipSelectPin 10
#include "TMRpcm.h"
#include "SPI.h"

TMRpcm tmrpcm;

void setup()
{
tmrpcm.speakerPin=9;
Serial.begin(9600);
if(!SD.begin(SD_ChipSelectPin))
{
  Serial.println("SD fail");
  return;
}
tmrpcm.setVolume(6);
tmrpcm.play("test.wav");

}

void loop() {
  // put your main code here, to run repeatedly:

}

SC to pin 10
SCK to pin 13
MOSI to pin 11
MISO to pin 12
VCC to 5v
GND to GND

positive speaker pin to 9
negative speaker pin to GND

Show a diagram. Describe what you observe.

  • You cannot drive a speaker with a GPIO pin.
1 Like

not that one anyway. You need either an amplifier - if you want 1W out; or a
piezo speaker like this - but it will be quiet.
30mm Piezo Transducer 150mm Leads — Switch Electronics | Your One Stop Component Shop?

...