You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Simple WAV file player example
  2. //
  3. // Requires the audio shield:
  4. // http://www.pjrc.com/store/teensy3_audio.html
  5. //
  6. // Data files to put on your SD card can be downloaded here:
  7. // http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
  8. //
  9. // This example code is in the public domain.
  10. #include <Audio.h>
  11. #include <Wire.h>
  12. #include <SPI.h>
  13. #include <SD.h>
  14. // GUItool: begin automatically generated code
  15. AudioPlaySdWav playWav1; //xy=154,78
  16. AudioOutputI2S i2s1; //xy=334,89
  17. AudioConnection patchCord1(playWav1, 0, i2s1, 0);
  18. AudioConnection patchCord2(playWav1, 1, i2s1, 1);
  19. AudioControlSGTL5000 sgtl5000_1; //xy=240,153
  20. // GUItool: end automatically generated code
  21. void setup() {
  22. Serial.begin(9600);
  23. // Audio connections require memory to work. For more
  24. // detailed information, see the MemoryAndCpuUsage example
  25. AudioMemory(5);
  26. sgtl5000_1.enable();
  27. sgtl5000_1.volume(0.5);
  28. SPI.setMOSI(7);
  29. SPI.setSCK(14);
  30. if (!(SD.begin(10))) {
  31. // stop here, but print a message repetitively
  32. while (1) {
  33. Serial.println("Unable to access the SD card");
  34. delay(500);
  35. }
  36. }
  37. }
  38. void playFile(const char *filename)
  39. {
  40. Serial.print("Playing file: ");
  41. Serial.println(filename);
  42. // Start playing the file. This sketch continues to
  43. // run while the file plays.
  44. playWav1.play(filename);
  45. // A brief delay for the library read WAV info
  46. delay(5);
  47. // Simply wait for the file to finish playing.
  48. while (playWav1.isPlaying()) {
  49. // uncomment these lines if you audio shield
  50. // has the optional volume pot soldered
  51. //float vol = analogRead(15);
  52. //vol = vol / 1024;
  53. // sgtl5000_1.volume(vol);
  54. }
  55. }
  56. void loop() {
  57. playFile("SDTEST1.WAV");
  58. delay(500);
  59. playFile("SDTEST2.WAV");
  60. delay(500);
  61. playFile("SDTEST3.WAV");
  62. delay(500);
  63. playFile("SDTEST4.WAV");
  64. delay(1500);
  65. }