Problem with 2 channels read reading

Status
Not open for further replies.

altra22

New Member
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
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);
   }
}
Sorry for read reading thingy i cant change the title
regards
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…