soundTrigger.ino 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <Audio.h>
  2. #include <Wire.h>
  3. #include <SPI.h>
  4. #include <SD.h>
  5. #include <SerialFlash.h>
  6. AudioPlaySdWav playWav1;
  7. AudioOutputI2S audioOutput;
  8. AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
  9. AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
  10. AudioControlSGTL5000 sgtl5000_1;
  11. // Use these with the Teensy Audio Shield
  12. #define SDCARD_CS_PIN 10
  13. #define SDCARD_MOSI_PIN 7
  14. #define SDCARD_SCK_PIN 14
  15. int buttonPins[11] = { 0, 1, 2, 3, 4, 5, 8, 16, 17, 20, 21 } ;
  16. //int buttonPin1 = 0 ;
  17. //int buttonPin2 = 1 ;
  18. //function prototypes
  19. void eventuallyContext();
  20. void trigSound(String);
  21. #include "evtActions.h"
  22. void setup() {
  23. // Serial.begin(9600) ;
  24. // Serial.println("started");
  25. AudioMemory(8);
  26. sgtl5000_1.enable();
  27. sgtl5000_1.volume(0.5);
  28. SPI.setMOSI(SDCARD_MOSI_PIN);
  29. SPI.setSCK(SDCARD_SCK_PIN);
  30. if (!(SD.begin(SDCARD_CS_PIN))) {
  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. for (int i ; i<sizeof(buttonPins) ; i++ ) {
  38. pinMode(buttonPins[i], INPUT_PULLUP);
  39. }
  40. eventuallyContext();
  41. }
  42. USE_EVENTUALLY_LOOP(mgr)