darioconcilio
Well-known member
Hi guys,
I met a problem about interference when I'm using PWM OUTPUT on LED and DAC OUPUT of my Teensy 3.2
This is the sketch that allowed me to understand this behavior.
As you can see from the sketch the audio part has not yet been used, but only set.
If I turn on my led using digitalWrite, audio output is OFF, ok good. Nothing noise.
But I a try ti creare a "behaviour" of my led or only turn on LED with a "middle" light, I hear a noise in OUPUT of DAC's Teensy 3.2.
What can I do to avoid this problem?
Can I decouple the PWM signal from the DAC?
I met a problem about interference when I'm using PWM OUTPUT on LED and DAC OUPUT of my Teensy 3.2
This is the sketch that allowed me to understand this behavior.
As you can see from the sketch the audio part has not yet been used, but only set.
If I turn on my led using digitalWrite, audio output is OFF, ok good. Nothing noise.
But I a try ti creare a "behaviour" of my led or only turn on LED with a "middle" light, I hear a noise in OUPUT of DAC's Teensy 3.2.
What can I do to avoid this problem?
Can I decouple the PWM signal from the DAC?
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySerialflashRaw playFlashRaw2; //xy=1959,2326
AudioSynthWaveformSine sine1; //xy=1961,2401
AudioPlaySerialflashRaw playFlashRaw1; //xy=1964,2274
AudioMixer4 mixer1; //xy=2276,2364
AudioOutputAnalog dac1; //xy=2642,2365
AudioConnection patchCord1(playFlashRaw2, 0, mixer1, 1);
AudioConnection patchCord2(sine1, 0, mixer1, 3);
AudioConnection patchCord3(playFlashRaw1, 0, mixer1, 0);
AudioConnection patchCord4(mixer1, dac1);
// GUItool: end automatically generated code
int color = 0;
void setup() {
SPI.setSCK(14);
SPI.setMOSI(11);
SPI.setMISO(12);
//analogWriteResolution(7);
AudioMemory(16);
mixer1.gain(0, 1);
mixer1.gain(1, 1);
mixer1.gain(3, 1);
sine1.amplitude(0);
sine1.frequency(880);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
// analogWrite(3, 120);
// analogWrite(4, 0);
// analogWrite(5, 0);
// analogWrite(6, 0);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
void loop() {
// color++;
//
// if(color>255) {
// color = 0;
// }
//
// analogWrite(3, color);
// delay(100);
}