I've read some discussions but still can't figure out how to get audio(SD card wav file) output from dac pins on T3.5/3.6.
I tested on T3.2 with audio shield it works fine. The file is ok, the speaker is ok, the sensor is ok.
Is there any example sketch that use dac output on T3.5/3.6?
Please help me out!
Thanks
I tested on T3.2 with audio shield it works fine. The file is ok, the speaker is ok, the sensor is ok.
Is there any example sketch that use dac output on T3.5/3.6?
Please help me out!
Thanks
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1; //xy=107,61
AudioPlaySdWav playSdWav2; //xy=108,126
AudioMixer4 mixer1; //xy=429,117
AudioOutputAnalog dac1; //xy=766,61
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord2(playSdWav1, 1, mixer1, 1);
AudioConnection patchCord3(playSdWav2, 0, mixer1, 2);
AudioConnection patchCord4(playSdWav2, 1, mixer1, 3);
AudioConnection patchCord5(mixer1, dac1);
// GUItool: end automatically generated code
int last = 0;
const int chipSelect = BUILTIN_SDCARD;
void setup() {
Serial.begin(9600);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(8);
pinMode(13, OUTPUT); // LED on pin 13
mixer1.gain(0, 1);
mixer1.gain(1, 1);
mixer1.gain(2, 1);
mixer1.gain(3, 1);
delay(1000);
}
void loop() {
int current = analogRead(A2);
if (current > 70 && abs(current - last) > 7) {
// decreasing
if (current < last && playSdWav2.isPlaying() == false) {
Serial.println("Start playing 2");
playSdWav1.stop();
playSdWav2.play("out-16.wav");
delay(200); // wait for library to parse WAV info
}
// increasing
else if (current > last && playSdWav1.isPlaying() == false){
Serial.println("Start playing 1, last = ");
playSdWav2.stop();
playSdWav1.play("in-16.wav");
delay(200); // wait for library to parse WAV info
}
}
last = current;
Serial.println(current);
delay(10);
}
Last edited: