0% found this document useful (0 votes)
14 views4 pages

Pic 1

The document includes code for initializing and controlling an LCD display module connected to a PIC microcontroller. It defines macros for the LCD data and control pins. Functions are declared for initializing the LCD, sending command/data, and displaying strings. The main loop clears the LCD, displays a string, then increments or decrements a counter variable if buttons are pressed and updates the LCD, looping until a stop button is pressed.

Uploaded by

nguyentram3432
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)
14 views4 pages

Pic 1

The document includes code for initializing and controlling an LCD display module connected to a PIC microcontroller. It defines macros for the LCD data and control pins. Functions are declared for initializing the LCD, sending command/data, and displaying strings. The main loop clears the LCD, displays a string, then increments or decrements a counter variable if buttons are pressed and updates the LCD, looping until a stop button is pressed.

Uploaded by

nguyentram3432
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/ 4

Lcd đ m ế

#include <p184520.h>
#include‹stdio.h>
#include ‹delays.h>

#pragma config OSC = HS


#pragma config WDT = OFF
#pragma config MCLRE = ON
#pragma config LVP = OFF
#pragma config PBADEN = OFF
#define lcd PORTD
#define RS PORTEbits. RE1
#define RW PORTEbits.RE2
#define A2 PORTAbits.RA2
#define A3 PORTAbits. RA3
#define A4 PORTAbits. RA4
#define Key PORTBbits.RB3
#define Up PORTBbits. RB0
#define Down PORTBbits.RB1
#define Stop PORTBbits. RB2

char m [20];
void lcd_cauhinh (void);
void lcd_caidat (char caidat);
void lcd_dulieu (char dulieu) ;
void lcd_chuoi (char *str);

void led cauhinh(void)

led caidat (0x03); led caidat (0x38);

ế
Lcd đ m 1
lcd caidat(0x06); lcd_caidat (OxOc); lcd_caidat(0x01);
}

void lcd_caidat (char caidat)

RS=0;
RW=0;
A2=1;
A3=1;
A4=1;
lcd=caidat;
A2=0;
A3=0;
A4=0;
Delay1KTCYx (1);
void lcd_dulieu(char dulieu)
RS=1;
RW=O;
A2=1;
A3=1;
A4=1;
1cd=dulieu;
A2=0;
A3=0;
A4=0;
Delay1KTCYX(1);
}
void lcd_chuoi(char *str)

{
while(*str
)

lcd dulieu(*str);
str++;

ế
Lcd đ m 2
}

}
while (1)
{
lcd_caidat (ex80);
sprintf (&m(0], "ngphuengoctraam.");
lcd_chuoi (8m[0]);
Key=0;
if (Up==0)t=1;
if (Down==0)t=2; if (Stop==0)t=0;
if(t==1)
{
for (dem=dem; dem<59 ; dem++)
{

if(Stop==0)break;
lcd_caidat (Oxce)
Delay10KTCYx (40);
sprintf (&m[0], "so dem =%3d", dem) ;
lcd_chuoi (&m[0]);

}
}

if (t==2)

for (dem=dem; dem>0 ; dem- - )


{

if(Stop==0)break;
lcd_caidat(0xc0):
Delay10KTCYx(40);
sprintf (&m[0], "so dem =%3d", dem) ;
lcd_chuoi (&m[0]);

}
}

ế
Lcd đ m 3
}

ế
Lcd đ m 4

You might also like