Analog to digital 8 bits For CSS Compiler

 

#include <16F877.h>
#device adc=8
#FUSES NOWDT ,XT                                        
#use delay(clock=4000000) 

#include <Lcd_4bit.c>
int8  value; 

void main()
{
   setup_adc_ports(AN0_AN1_AN3);
   setup_adc(ADC_CLOCK_DIV_2);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1); 
   set_adc_channel(0);
   set_tris_d(0x00);
   set_tris_A(0xff);
   Lcd_init();

while(true){ 
   set_adc_channel(0);
   delay_ms(10);
   value = read_adc(); // 0-1023  
   Lcd_row_col(1,0);   
   Lcd_putc("setpoint=");
   hex_bcd(value);lcd_row_col(1,9);sent_Lcd(); 
   delay_ms(50);   
  }
}

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter