Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

balanceHP.ino 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* HP balance example: Will influence only HP output.
  2. This example code is in the public domain
  3. */
  4. #include <Audio.h>
  5. #include <Wire.h>
  6. #include <SPI.h>
  7. #include <SD.h>
  8. #include <SerialFlash.h>
  9. const int myInput = AUDIO_INPUT_LINEIN;
  10. // const int myInput = AUDIO_INPUT_MIC;
  11. // Create the Audio components. These should be created in the
  12. // order data flows, inputs/sources -> processing -> outputs
  13. //
  14. AudioInputI2S audioInput; // audio shield: mic or line-in
  15. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  16. // Create Audio connections between the components
  17. // Just connecting in to out
  18. AudioConnection c1(audioInput, 0, audioOutput, 0); // left connection
  19. AudioConnection c2(audioInput, 1, audioOutput, 1); // right connection
  20. // Create an object to control the audio shield.
  21. //
  22. AudioControlSGTL5000 audioShield;
  23. void setup() {
  24. // Audio connections require memory to work. For more
  25. // detailed information, see the MemoryAndCpuUsage example
  26. AudioMemory(4);
  27. // Enable the audio shield and set the output volume.
  28. audioShield.enable();
  29. audioShield.inputSelect(myInput);
  30. audioShield.volume(0.5);
  31. }
  32. elapsedMillis chgMsec=0;
  33. float lastBal=1024;
  34. float vol1=0.75;
  35. void loop() {
  36. // every 10 ms, check for adjustment
  37. if (chgMsec > 10) {
  38. float bal1=analogRead(15);
  39. bal1=((bal1-512)/512);
  40. bal1=(int)bal1;
  41. if(lastBal!=bal1)
  42. {
  43. if(bal1<0)
  44. {
  45. audioShield.volume(vol1,vol1*(1+bal1));
  46. } else {
  47. audioShield.volume(vol1*(1-bal1),vol1);
  48. }
  49. lastBal=bal1;
  50. }
  51. chgMsec = 0;
  52. }
  53. }