Hi all, I built this attached circuit with a couple changes to analyze audio (changes listed below). It worked before, but when I tested it again today, it just stopped working. My code below prints 127 (half of 255 due to my DC offset) to the serial monitor just fine, but when I play audio, the value stays at 127 and does not fluctuate as it did before.
What I know is that when I tested it today, I started smelling smoke, but I couldn't identify where the smoke smell was coming from. I felt one of the batteries, and it was significantly warmer than the other one. My jumper cables connecting to the batteries do have exposed ends (rookie mistake), is it possible that they touched another part and fried some part of the circuit? Should I rebuild the entire circuit with new parts?
Changes to circuit:
-removed 47nF capacitor
-voltage divider resistors are 10k
-feedback resistor 30k
-audio input is done by connecting iphone jack to a female socket with ground, sleeve, and tip pins. Sleeve and tip connected to 5k resistors, both fed into the noninverting input of op-amp.
byte incomingAudio; //setup A0 pin
boolean clipping = 0;
void setup(){
pinMode(13, OUTPUT); //LED clipping indicator pin
cli(); //disable interrupts
//set up continuous sampling of analog pin 0 (increase default sampling rate of 8000Hz from analogRead() function in order to increase resolution)
//clear ADCSRA and ADCSRB registers
ADCSRA = 0;
ADCSRB = 0;
ADMUX |= (1 << REFS0); //set reference voltage
ADMUX |= (1 << ADLAR); //left align the ADC value- so we can read highest 8 bits from ADCH register only
ADCSRA |= (1 << ADPS2) | (1 << ADPS0); //set ADC clock with 32 prescaler- 16mHz/32=500kHz
ADCSRA |= (1 << ADATE); //enable auto trigger
ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete
ADCSRA |= (1 << ADEN); //enable ADC
ADCSRA |= (1 << ADSC); //start ADC measurements
sei();//enable interrupts
Serial.begin(9600);
}
//Interrupt function: every 26us (13 clock cycles / 500000 Hz = 26us, or a rate of 38.5kHz), incomingAudio
//automatically updated: pauses loop() every 26us to run then continues loop()
ISR(ADC_vect) //when new ADC value ready
{
incomingAudio = ADCH;//update the variable incomingAudio with new value from A0 (between 0 and 255)
Serial.println(incomingAudio);
if(incomingAudio == 0 || incomingAudio == 255) //if audio at either value, means it is clipping
{
digitalWrite(13, HIGH); //turn LED on
clipping = 1; //clipping state ON (currently clipping)
}
}
void loop(){
if(clipping) //if currently clipping boolean 1 = true
{
clipping = 0;
digitalWrite(13, LOW); //turn LED off
}
delay(100); //wait so LED on is visible to human eye
}