Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

50 lines
1.3KB

  1. /*
  2. * A simple hardware test which receives audio from the audio shield
  3. * Line-In pins and send it to the Line-Out pins and headphone jack.
  4. *
  5. * This example code is in the public domain.
  6. */
  7. #include <Audio.h>
  8. #include <Wire.h>
  9. #include <SPI.h>
  10. #include <SD.h>
  11. // GUItool: begin automatically generated code
  12. AudioInputI2S i2s1; //xy=200,69
  13. AudioOutputI2S i2s2; //xy=365,94
  14. AudioConnection patchCord1(i2s1, 0, i2s2, 0);
  15. AudioConnection patchCord2(i2s1, 1, i2s2, 1);
  16. AudioControlSGTL5000 sgtl5000_1; //xy=302,184
  17. // GUItool: end automatically generated code
  18. const int myInput = AUDIO_INPUT_LINEIN;
  19. //const int myInput = AUDIO_INPUT_MIC;
  20. void setup() {
  21. // Audio connections require memory to work. For more
  22. // detailed information, see the MemoryAndCpuUsage example
  23. AudioMemory(12);
  24. // Enable the audio shield, select input, and enable output
  25. sgtl5000_1.enable();
  26. sgtl5000_1.inputSelect(myInput);
  27. sgtl5000_1.volume(0.5);
  28. }
  29. elapsedMillis volmsec=0;
  30. void loop() {
  31. // every 50 ms, adjust the volume
  32. if (volmsec > 50) {
  33. float vol = analogRead(15);
  34. vol = vol / 1023.0;
  35. //audioShield.volume(vol); // <-- uncomment if you have the optional
  36. volmsec = 0; // volume pot on your audio shield
  37. }
  38. }