USING ADC IN PIC MICROCONTROLLER USING CCS C COMPILER

proteus model:adc

SOURCE CODE: CCS C COMPILER

#include <16F877.h>
#device ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include “lcd.c”
void main (void)
{
long m_Adc_Value=0;
float m_Voltages=0.0;
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
setup_adc(ADC_CLOCK_INTERNAL );
lcd_init();
while(1)
{
set_adc_channel(0);
m_Adc_Value=read_adc();
m_Voltages=(m_Adc_Value/1024.0)*5.0;
lcd_gotoxy(1,1);
m_voltages=m_voltages;
printf(lcd_putc,”Voltages= %f “,5*m_Voltages);
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s