Hello, I am trying to create a sketch that uses control registers to take two temperatures, one from a tmp36 and the other from the internal sensor on the arduino uno. The temperature from the tmp36 looks fine, but I am getting a negative number for the internal sensor reading. I figure it is a mistake i made in programming the registers. Any help would be greatly appreciated. Here is what I have:
volatile float temp = 0; //declare variable analogValue and assign value 0
void setup() {
Serial.begin(9600); //set baud rate to 9600
interrupts(); //enable interrupts*/
}
void loop() {
ADMUX = 0b11001000; //assign bits to register ADMUX
ADCSRA = 0b11001111; //assign bits to register ADCSRA
ADCSRB = 0b00000000; //assign bits to register ADCSRB
Serial.println(((temp / 1024.00 * 5.00) - 0.5) * 100.00);
ADCSRA |= (1<<ADSC);
delay(500);
ADMUX = 0b01000000; //assign bits to register ADMUX
ADCSRA = 0b11001111; //assign bits to register ADCSRA
ADCSRB = 0b00000000; //assign bits to register ADCSRB
//temp = ((analogRead(A0) / 1024.00 * 5.00) - 0.5) * 100;
Serial.println(((temp / 1024.00 * 5.00) - 0.5) * 100.00);
ADCSRA |= (1<<ADSC);
delay(500);
}
ISR(ADC_vect){
temp = ADC;
}
ADCtemp.ino (926 Bytes)