Arduino Forum

Products => Arduino Zero => Topic started by: imagia on Dec 30, 2015, 10:38 pm

Title: Mic Analog to DAC output
Post by: imagia on Dec 30, 2015, 10:38 pm
I write simple sketch to read voice via mic and output to DAC speaker.

This sketch works very poor. Voice is unclean :(

Please answer what is wrong ?

Thanks!



Code: [Select]
void setup() {
   analogReadResolution(8);
   analogWriteResolution(12);
   Serial.begin(9600);
}

void loop() {
//int sensorValue=  map (analogRead(A5),0,4095,0,1023);  //
int sensorValue= analogRead(A5)<<2;

// Serial.println(analogRead(A5));
 analogWrite(A0, sensorValue);
}
Title: Re: Mic Analog to DAC output
Post by: imagia on Dec 31, 2015, 11:05 am
Now works very good :)
MIC with amp connect to A1 with 3,3V power

Code: [Select]

int sensorPin = A1;
int sensorValue = 0;

void setup() {
   analogReadResolution(8);
   analogWriteResolution(16);
   Serial.begin(9600);
   ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC0_Val;
   ADC->AVGCTRL.reg = 0x00;      //Single conversion no averaging
   GCLK->CLKCTRL.reg = 0x431E;   //enable GGCLK for ADC, CLKGEN3 = 8 MHz oscillator
   ADC->CTRLB.reg =  0x000;      // Prescale 4, 12 bit resolution, single conversion
}

void loop() {
//sensorValue=  map (analogRead(A5),0,4096,0,1023);
 sensorValue= analogRead(sensorPin)<<1;
// Serial.println(analogRead(A5));
 analogWrite(A0, sensorValue);
}