HUNMAN
Published © MIT

Speaker with Arduino and Micro SD

This trick teaches you how to use Micro SD/SD card for Arduino and speaker.

BeginnerShowcase (no instructions)31,897
Speaker with Arduino and Micro SD

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
arduino uno(only)
×1
Speaker: 0.25W, 8 ohms
Speaker: 0.25W, 8 ohms
speaker 8 ohm
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
male//female
×6
MicroSD Module (Generic)
micro sd card module
×1

Software apps and online services

Arduino IDE
Arduino IDE
ide arduino

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Schematics

scematic

Code

socure code

Arduino
#include <SD.h>                           //include SD module library
#include <TMRpcm.h>                       //include speaker control library

#define SD_ChipSelectPin 4                //define CS pin

TMRpcm tmrpcm;                            //crete an object for speaker library

void setup(){
  
  tmrpcm.speakerPin = 9;                  //define speaker pin. 
                                          //you must use pin 9 of the Arduino Uno and Nano
                                          //the library is using this pin
  
  if (!SD.begin(SD_ChipSelectPin)) {      //see if the card is present and can be initialized
    
    return;                               //don't do anything more if not
  }
  
  tmrpcm.setVolume(6);                    //0 to 7. Set volume level
  tmrpcm.play("1.wav");         //the sound file "1" will play each time the arduino powers up, or is reset
}

void loop(){}

Credits

HUNMAN

HUNMAN

2 projects • 8 followers

Comments