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);   
  }
}




Leave a Comment

*
= 5 + 8

Read previous post:
Schematic How to make(build) a Calculator using Pic16f877 microcontroller
How to make(build) a Calculator using Pic16f877 microcontroller

Calculator with Pic 16f877 microcontroller is a comprehensive project. Comprehensive in the way that Code is lengthy and logical. It...

Close
Scroll to top