Advertisement
Guest User

geluidjedingarduino

a guest
Sep 19th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SD.h>                       // need to include the SD library
  2. //#define SD_ChipSelectPin 53         // example uses hardware SS pin 53 on Mega2560
  3. #define SD_ChipSelectPin 10            // using digital pin 10 on arduino uno 328, can use other pins
  4. #include <TMRpcm.h>                   // also need to include this library...
  5. #include <SPI.h>
  6.  
  7. TMRpcm tmrpcm;
  8.  
  9. void setup()
  10. {
  11. tmrpcm.speakerPin=9;            //5,6,11 or 46 on Mega, 9 on Uno, Nano, etc
  12.                                 //Complimentary Output or Dual Speakers:
  13.                                 //pinMode(10,OUTPUT); Pin pairs: 9,10 Mega: 5-2,6-7,11-12,46-45
  14. Serial.begin(9600);
  15. if(!SD.begin(SD_ChipSelectPin))
  16.   {
  17.     Serial.println("SD fail");
  18.   }
  19. }
  20.  
  21. void loop() {
  22.   char filename[] = "test.wav";
  23.  
  24.   tmrpcm.setVolume(4);
  25.   tmrpcm.play(filename);
  26.   delay(3000);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement