|Hello to the AVR community.
I have written a code that take analog values from my hardware and through a bluetooth working in serial port profile displays data on the hyperterminal.I am using an atmega168 processor.
I successfully, after a lot of struggle was able to transmit data over the UART and was able to display float values but the values that I get are incorrect.
I am posting my code below....any help or suggestions as to why I get a constant stream of -64's for all my analog values would be really helpful.
uint16_t readADC(int pin)
uint8_t low, high;
ADMUX =(1<<ADLAR)|(0<<REFS1)|(0<<REFS0)|(pin & 0x0F);
// start conversion
// ADSC is cleared when the conversion finishes
while (bit_is_set(ADCSRA, ADSC));
low = ADCL;
high = ADCH;
// combine the two bytes
sample = (high << 8) | (low & 0xFF);
Vout=-64 Vbias=-64 X=-64 Y=-64 Z=-64, Number:295