Hi All,
I'm having trouble getting audio output on a TeensyLC from the DAC pin. It was bouncing around in my toolbox for a while and if I've damaged it somehow I don't mind replacing it, but it seems to be working otherwise so I'm wondering if anyone had any troubleshooting suggestions.
Specifically, I'm able to get a tone from an 8ohm speaker connected up to the DAC pin with the following code:
But the following code (which I found on this forum a while back, and was making a series of alternating tones on this TeensyLC a couple weeks ago), is giving me total silence:
I apologize if I'm being dense about something here, but this has completely stumped me two nights in a row and I'd love to be able to have some leads on troubleshooting or go ahead and order a replacement board if that's my best bet.
I'm having trouble getting audio output on a TeensyLC from the DAC pin. It was bouncing around in my toolbox for a while and if I've damaged it somehow I don't mind replacing it, but it seems to be working otherwise so I'm wondering if anyone had any troubleshooting suggestions.
Specifically, I'm able to get a tone from an 8ohm speaker connected up to the DAC pin with the following code:
Code:
void setup() {
Serial.begin(9600);
pinMode(A12,OUTPUT);
}
void loop() {
tone(A12,220,100);
delay(1000);
}
But the following code (which I found on this forum a while back, and was making a series of alternating tones on this TeensyLC a couple weeks ago), is giving me total silence:
Code:
#include <Audio.h>
#include <Wire.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=418,255
AudioOutputAnalog dac1; //xy=582,250
AudioConnection patchCord1(waveform1, dac1);
// GUItool: end automatically generated code
elapsedMillis sinceFormChange;
//
//define WAVEFORM_SINE 0
//define WAVEFORM_SAWTOOTH 1
//define WAVEFORM_SQUARE 2
//define WAVEFORM_TRIANGLE 3
//define WAVEFORM_ARBITRARY 4
//define WAVEFORM_PULSE 5
//define WAVEFORM_SAWTOOTH_REVERSE 6
//define WAVEFORM_SAMPLE_HOLD 7
//define WAVEFORM_TRIANGLE_VARIABLE 8
int forms[5] = {WAVEFORM_SINE, WAVEFORM_SAWTOOTH, WAVEFORM_SAWTOOTH_REVERSE, WAVEFORM_TRIANGLE, WAVEFORM_SQUARE};
int currentForm = -1;
void setup() {
AudioMemory(10);
sinceFormChange = 2001; // don't wait for the first update
}
void loop() {
delay(100); // to be replaced with reading pots and switches
if (sinceFormChange > 2000) {
waveform1.begin(forms[++currentForm]);
waveform1.frequency(100);
waveform1.amplitude(0.8);
sinceFormChange = 0;
if (currentForm >= 4) {
currentForm = -1;
}
}
}
I apologize if I'm being dense about something here, but this has completely stumped me two nights in a row and I'd love to be able to have some leads on troubleshooting or go ahead and order a replacement board if that's my best bet.