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 holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter