Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * AK4558 Sine Out Test
  3. * 2015 by Michele Perla
  4. *
  5. * A simple hardware test which sends two 440 Hz sinewaves to the
  6. * LOUT/ROUT pins of the HiFi Audio CODEC Module. One of the waves
  7. * is out-of-phase by 90° with the other.
  8. *
  9. */
  10. #include <Audio.h>
  11. #include <Wire.h>
  12. #include <SPI.h>
  13. #include <SD.h>
  14. #include <SerialFlash.h>
  15. AudioSynthWaveformSine sine2;
  16. AudioSynthWaveformSine sine1;
  17. AudioOutputI2S i2s1;
  18. AudioConnection patchCord1(sine2, 0, i2s1, 0);
  19. AudioConnection patchCord2(sine1, 0, i2s1, 1);
  20. AudioControlAK4558 ak4558;
  21. int phase = 0;
  22. void setup() {
  23. // put your setup code here, to run once:
  24. AudioMemory(12);
  25. while (!Serial);
  26. ak4558.enable();
  27. AudioNoInterrupts();
  28. sine1.frequency(440);
  29. sine2.frequency(440);
  30. sine1.amplitude(1.0);
  31. sine2.amplitude(1.0);
  32. AudioInterrupts();
  33. }
  34. void loop() {
  35. phase+=10;
  36. if (phase==360) phase=0;
  37. AudioNoInterrupts();
  38. sine2.phase(phase);
  39. AudioInterrupts();
  40. delay(250);
  41. }