Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

78 linhas
2.1KB

  1. // Quad channel output test
  2. // Play two WAV files on two audio shields.
  3. //
  4. // TODO: add info about required hardware connections here....
  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. #include <SerialFlash.h>
  15. AudioPlaySdWav playSdWav1;
  16. AudioPlaySdWav playSdWav2;
  17. AudioOutputI2SQuad audioOutput;
  18. AudioConnection patchCord1(playSdWav1, 0, audioOutput, 0);
  19. AudioConnection patchCord2(playSdWav1, 1, audioOutput, 1);
  20. AudioConnection patchCord3(playSdWav2, 0, audioOutput, 2);
  21. AudioConnection patchCord4(playSdWav2, 1, audioOutput, 3);
  22. AudioControlSGTL5000 sgtl5000_1;
  23. AudioControlSGTL5000 sgtl5000_2;
  24. // Use these with the Teensy Audio Shield
  25. #define SDCARD_CS_PIN 10
  26. #define SDCARD_MOSI_PIN 7
  27. #define SDCARD_SCK_PIN 14
  28. // Use these with the Teensy 3.5 & 3.6 SD card
  29. //#define SDCARD_CS_PIN BUILTIN_SDCARD
  30. //#define SDCARD_MOSI_PIN 11 // not actually used
  31. //#define SDCARD_SCK_PIN 13 // not actually used
  32. // Use these for the SD+Wiz820 or other adaptors
  33. //#define SDCARD_CS_PIN 4
  34. //#define SDCARD_MOSI_PIN 11
  35. //#define SDCARD_SCK_PIN 13
  36. void setup() {
  37. Serial.begin(9600);
  38. AudioMemory(10);
  39. sgtl5000_1.setAddress(LOW);
  40. sgtl5000_1.enable();
  41. sgtl5000_1.volume(0.5);
  42. sgtl5000_2.setAddress(HIGH);
  43. sgtl5000_2.enable();
  44. sgtl5000_2.volume(0.5);
  45. SPI.setMOSI(SDCARD_MOSI_PIN);
  46. SPI.setSCK(SDCARD_SCK_PIN);
  47. if (!(SD.begin(SDCARD_CS_PIN))) {
  48. // stop here, but print a message repetitively
  49. while (1) {
  50. Serial.println("Unable to access the SD card");
  51. delay(500);
  52. }
  53. }
  54. }
  55. void loop() {
  56. if (playSdWav1.isPlaying() == false) {
  57. Serial.println("Start playing 1");
  58. playSdWav1.play("SDTEST2.WAV");
  59. delay(10); // wait for library to parse WAV info
  60. }
  61. if (playSdWav2.isPlaying() == false) {
  62. Serial.println("Start playing 2");
  63. playSdWav2.play("SDTEST4.WAV");
  64. delay(10); // wait for library to parse WAV info
  65. }
  66. }