0% found this document useful (0 votes)
40 views3 pages

Adc

The document contains code for interfacing an LCD module with a microcontroller, including pin connections and initialization functions. It reads an analog value from an ADC, converts it to a voltage, and displays the result on the LCD. The program also shows a welcome message and clears the display at intervals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views3 pages

Adc

The document contains code for interfacing an LCD module with a microcontroller, including pin connections and initialization functions. It reads an analog value from an ADC, converts it to a voltage, and displays the result on the LCD. The program also shows a welcome message and clears the display at intervals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

// LCD module connections

sbit LCD_RS at RB0_bit;

sbit LCD_EN at RB1_bit;

sbit LCD_D4 at RB2_bit;

sbit LCD_D5 at RB3_bit;

sbit LCD_D6 at RB4_bit;

sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;

sbit LCD_EN_Direction at TRISB1_bit;

sbit LCD_D4_Direction at TRISB2_bit;

sbit LCD_D5_Direction at TRISB3_bit;

sbit LCD_D6_Direction at TRISB4_bit;

sbit LCD_D7_Direction at TRISB5_bit;

// End LCD module connections

void main() {

unsigned int adc_Re=0;

float adc_value;

char y[15];

Lcd_Init();

ADC_Init();

Lcd_Cmd(_lcd_cursor_off);

Lcd_Cmd(_lcd_Clear);

Lcd_out(1,2,"KALDOUN MOHSEN");

Lcd_out(2,2,"Reg.No:166072");

delay_ms(1000);

Lcd_Cmd(_lcd_Clear); Lcd_out(1,7,"B5EC"); Lcd_out(2,7,"A D C");

delay_ms(1000);

Lcd_Cmd(_lcd_Clear);

portb=0; trisA=1; PortA=0;

while(1){

adc_Re=ADC_Get_sample(0); adc_value=(adc_Re*5.0)/1023.0; floatToStr(adc_value,y);

Lcd_out(2,3,"Volt=");

Lcd_out(2,9,y);

Delay_ms(100);

}}

You might also like