No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

QuadChannelOutput.ino 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 audio adaptor board
  25. #define SDCARD_CS_PIN 10
  26. #define SDCARD_MOSI_PIN 7
  27. #define SDCARD_SCK_PIN 14
  28. void setup() {
  29. Serial.begin(9600);
  30. AudioMemory(10);
  31. sgtl5000_1.setAddress(LOW);
  32. sgtl5000_1.enable();
  33. sgtl5000_1.volume(0.5);
  34. sgtl5000_2.setAddress(HIGH);
  35. sgtl5000_2.enable();
  36. sgtl5000_2.volume(0.5);
  37. SPI.setMOSI(SDCARD_MOSI_PIN);
  38. SPI.setSCK(SDCARD_SCK_PIN);
  39. if (!(SD.begin(SDCARD_CS_PIN))) {
  40. // stop here, but print a message repetitively
  41. while (1) {
  42. Serial.println("Unable to access the SD card");
  43. delay(500);
  44. }
  45. }
  46. }
  47. void loop() {
  48. if (playSdWav1.isPlaying() == false) {
  49. Serial.println("Start playing 1");
  50. playSdWav1.play("SDTEST2.WAV");
  51. delay(10); // wait for library to parse WAV info
  52. }
  53. if (playSdWav2.isPlaying() == false) {
  54. Serial.println("Start playing 2");
  55. playSdWav2.play("SDTEST4.WAV");
  56. delay(10); // wait for library to parse WAV info
  57. }
  58. }