mamech
Full Member level 3
Hello
I tried to read from analog pin and read it on my computer using terminal program. I used the following code:
unsigned int temp_res;
void main() {
ADCON0 = 0x00;
TRISA = 0xFF;
TRISC = 0;
TRISB = 0;
UART1_Init(9600);
Delay_ms(100);
UART1_Write_Text("Start");
UART1_Write(10);
UART1_Write(13);
do {
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
if (UART1_Data_Ready()) { // If data is received,
UART1_Write(temp_res); // and send data via UART
}
PORTB = ~ Portb;
Delay_ms(2000);
} while(1);
}
So I am reading the value on the pin and send it by serial to computer. I change the value of the analog i/p using a pot.
But there are a problem facing me. The value that I read on terminal program swings and does not stabilize even if I disconnected the pot and connected the supply directly.
Why does this happen?
I tried to read from analog pin and read it on my computer using terminal program. I used the following code:
unsigned int temp_res;
void main() {
ADCON0 = 0x00;
TRISA = 0xFF;
TRISC = 0;
TRISB = 0;
UART1_Init(9600);
Delay_ms(100);
UART1_Write_Text("Start");
UART1_Write(10);
UART1_Write(13);
do {
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
if (UART1_Data_Ready()) { // If data is received,
UART1_Write(temp_res); // and send data via UART
}
PORTB = ~ Portb;
Delay_ms(2000);
} while(1);
}
So I am reading the value on the pin and send it by serial to computer. I change the value of the analog i/p using a pot.
But there are a problem facing me. The value that I read on terminal program swings and does not stabilize even if I disconnected the pot and connected the supply directly.
Why does this happen?