📄 lesson6.c
字号:
#include <iom16v.h>
#include <macros.h>
#define uchar unsigned char
#define uint unsigned int
#pragma data:code
const uchar table[]="I LIKE AVR !";
const uchar table1[]="WWW.TXMCU.COM";
void delay(uint ms)
{
uint i,j;
for(i=0;i<ms;i++)
{
for(j=0;j<1141;j++);
}
}
void write_com(uchar com)
{
PORTD&=~BIT(4);
PORTD&=~BIT(5);
PORTB=com;
PORTD|=BIT(6);
delay(1);
PORTD&=~BIT(6);
}
void write_dat(uchar dat)
{
PORTD|=BIT(4);
PORTD&=~BIT(5);
PORTB=dat;
PORTD|=BIT(6);
delay(1);
PORTD&=~BIT(6);
}
void main()
{
uchar i;
DDRB=0XFF;
DDRD|=BIT(4)|BIT(5)|BIT(6);
PORTD&=~BIT(6);
write_com(0X38);
delay(5);
write_com(0X01);
delay(5);
write_com(0X0C);
delay(5);
write_com(0X06);
delay(5);
write_com(0X80+0X10);
delay(5);
for(i=0;i<12;i++)
{
write_dat(table[i]);
delay(5);
}
write_com(0X80+0X50);
delay(5);
for(i=0;i<13;i++)
{
write_dat(table1[i]);
delay(5);
}
for(i=0;i<16;i++)
{
write_com(0X18);
delay(500);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -