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.

52 lines
1.3KB

  1. #include <Audio.h>
  2. #include <Wire.h>
  3. #include <SPI.h>
  4. #include <SD.h>
  5. const int myInput = AUDIO_INPUT_LINEIN;
  6. //const int myInput = AUDIO_INPUT_MIC;
  7. // Create the Audio components. These should be created in the
  8. // order data flows, inputs/sources -> processing -> outputs
  9. //
  10. //AudioInputAnalog analogPinInput(16); // analog A2 (pin 16)
  11. AudioInputI2S audioInput; // audio shield: mic or line-in
  12. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  13. AudioOutputPWM pwmOutput; // audio output with PWM on pins 3 & 4
  14. // Create Audio connections between the components
  15. //
  16. AudioConnection c1(audioInput, 0, audioOutput, 0);
  17. AudioConnection c2(audioInput, 1, audioOutput, 1);
  18. AudioConnection c5(audioInput, 0, pwmOutput, 0);
  19. // Create an object to control the audio shield.
  20. //
  21. AudioControlSGTL5000 audioShield;
  22. void setup() {
  23. // Audio connections require memory to work. For more
  24. // detailed information, see the MemoryAndCpuUsage example
  25. AudioMemory(12);
  26. // Enable the audio shield and set the output volume.
  27. audioShield.enable();
  28. audioShield.inputSelect(myInput);
  29. audioShield.volume(0.6);
  30. }
  31. elapsedMillis volmsec=0;
  32. void loop() {
  33. // every 50 ms, adjust the volume
  34. if (volmsec > 50) {
  35. float vol = analogRead(15);
  36. vol = vol / 1023.0;
  37. audioShield.volume(vol);
  38. volmsec = 0;
  39. }
  40. }