void main()
{
float adc1,adc2;
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
while(1)
{
set_adc_channel(0);
delay_ms(10);
adc1=read_adc();
adc2=(adc1*5)/1023;
printf("adc=%f\r\n",adc2);
}
}
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
Make your lcd connection like that
LCD-------------Microcontroller
PIN ------------------PIN
1->Gnd
2->Vcc
3->Gnd
4------------------->22
5->Gnd
6->------------------>21
11------------------->27
12------------------->28
13------------------->29
14------------------->30
#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#include <give the location of the lcd driver file here\Flexlcd.c>
//===================================
void main()
{
// The lcd_init() function should always be called once,
// near the start of your program.
lcd_init();
// Clear the LCD.
printf(lcd_putc, "\f");
delay_ms(500);
while(1)
{
printf(lcd_putc, "\fABCDEFGHIJKLMNOPQRST");
printf(lcd_putc, "\nabcdefghijklmnopqrst");
delay_ms(3000);
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?