📄 untitled.c
字号:
#include<mega8535.h>
#include<delay.h>
#include<string.h>
#define RS PORTA.4
#define RW PORTA.5
#define EN PORTA.6
#define LCD_DATA PORTC
void LCD_CALL()
{
EN = 0;
delay_ms(10);
EN = 1;
}
void init_LCD()
{
RS = 0;
LCD_DATA = 0x38;
LCD_CALL();
delay_ms(2);
LCD_DATA = 0x0E;
LCD_CALL();
delay_ms(2);
LCD_DATA = 0x01;
LCD_CALL();
delay_ms(2);
LCD_DATA = 0x06;
LCD_CALL();
delay_ms(2);
LCD_DATA = 0x80;
LCD_CALL();
delay_ms(10);
//LCD_DATA = 0xC0;
//LCD_CALL();
}
void LCD_DAT(unsigned char data)
{
RS = 1;
LCD_DATA = data;
LCD_CALL();
}
void clear_lcd(void)
{
LCD_DATA = 0x01;
LCD_CALL();
delay_ms(20);
}
void main()
{
int i;
unsigned char a[]="I LOVE MY INDIA ";
DDRC = 0xFF;
DDRA = 0xFF;
RW = 0;
//init_LCD();
while(1)
{
PORTA = 0x03;
delay_ms(100);
PORTA = 0x00;
init_LCD();
//LCD_DAT('R');
for(i=0;a[i]!='\0';i++)
{
LCD_DAT(a[i]);
delay_ms(100);
}
clear_lcd();
delay_ms(100);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -