Problem with 2 channels reading A/D
Hi
iam trying to read 2 inputs from A/D
temperature and voltage the problem with update values in lcd
the temp is working perfect but the voltage , i must do hard reset to the Board to update the value of voltage
here is my code
Sorry for read reading thingy i cant change the title
regards
Hi
iam trying to read 2 inputs from A/D
temperature and voltage the problem with update values in lcd
the temp is working perfect but the voltage , i must do hard reset to the Board to update the value of voltage
here is my code
Code:
#include <16F876a.h>
#device ADC=10 // Use 10 bits
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#include <lcd.c>
#use fast_io(B)
float y,i,x,value;
void main()
{
lcd_init();
output_b(0x00);
set_tris_b(0x00);
// Setup A/D
setup_adc_ports(RA0_RA1_RA3_ANALOG); // Only RA0 as analog input
setup_adc(ADC_CLOCK_DIV_32); // Divide clock by 32
while(1)
{
set_adc_channel(0);
delay_ms(100);
i = read_adc();
x= (i*5/1023)-5 ;
// secound channel //
set_adc_channel(1);
delay_ms(100);
value = read_adc();
y = 5*value*100/1023;
printf(lcd_putc,"Volt is %f \nTemp is %f ",x,y);
}
}
regards
Last edited: