Devices & Components
Arduino Uno Rev3
Speaker: 0.25W, 8 ohms
Male/Female Jumper Wires
MicroSD Module (Generic)
Hardware & Tools
Hot glue gun (generic)
Software & Tools
Arduino IDE
Project description
Code
socure code
arduino
1#include <SD.h> //include SD module library 2#include <TMRpcm.h> //include speaker control library 3 4#define SD_ChipSelectPin 4 //define CS pin 5 6TMRpcm tmrpcm; //crete an object for speaker library 7 8void setup(){ 9 10 tmrpcm.speakerPin = 9; //define speaker pin. 11 //you must use pin 9 of the Arduino Uno and Nano 12 //the library is using this pin 13 14 if (!SD.begin(SD_ChipSelectPin)) { //see if the card is present and can be initialized 15 16 return; //don't do anything more if not 17 } 18 19 tmrpcm.setVolume(6); //0 to 7. Set volume level 20 tmrpcm.play("1.wav"); //the sound file "1" will play each time the arduino powers up, or is reset 21} 22 23void loop(){}
Downloadable files
scematic
scematic
scematic
scematic
Comments
Only logged in users can leave comments