Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

51 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. #include <SerialFlash.h>
  12. // GUItool: begin automatically generated code
  13. AudioInputI2S i2s1; //xy=200,69
  14. AudioOutputI2S i2s2; //xy=365,94
  15. AudioConnection patchCord1(i2s1, 0, i2s2, 0);
  16. AudioConnection patchCord2(i2s1, 1, i2s2, 1);
  17. AudioControlSGTL5000 sgtl5000_1; //xy=302,184
  18. // GUItool: end automatically generated code
  19. const int myInput = AUDIO_INPUT_LINEIN;
  20. //const int myInput = AUDIO_INPUT_MIC;
  21. void setup() {
  22. // Audio connections require memory to work. For more
  23. // detailed information, see the MemoryAndCpuUsage example
  24. AudioMemory(12);
  25. // Enable the audio shield, select input, and enable output
  26. sgtl5000_1.enable();
  27. sgtl5000_1.inputSelect(myInput);
  28. sgtl5000_1.volume(0.5);
  29. }
  30. elapsedMillis volmsec=0;
  31. void loop() {
  32. // every 50 ms, adjust the volume
  33. if (volmsec > 50) {
  34. float vol = analogRead(15);
  35. vol = vol / 1023.0;
  36. //audioShield.volume(vol); // <-- uncomment if you have the optional
  37. volmsec = 0; // volume pot on your audio shield
  38. }
  39. }