|
#include
#define uchar unsigned char
#define uint unsigned int
#define EH PORTB|=1;
#define EL PORTB&=~1;
#define RD PORTB|=(1<<1);
#define WR PORTB&=~(1<<1);
#define RSL PORTB&=~(1<<2);
#define RSH PORTB|=(1<<2);
uchar s=0;
uchar hu[2][32]=
{
{0x08,0x08,0xC8,0xFF,0x48,0x88,0x0A,0x42,
0x62,0xD2,0x4A,0xC6,0x42,0xC0,0x00,0x00,
0x04,0x03,0x00,0xFF,0x00,0x01,0x08,0x24,
0x13,0x08,0x06,0x41,0x80,0x7F,0x00,0x00},
{0x80,0x98,0x56,0x34,0x1F,0xF4,0x54,0x88,
0x56,0x34,0x1F,0x74,0x94,0x94,0xC0,0x00,
0x00,0x80,0x80,0x5F,0x41,0x21,0x11,0x0F,
0x11,0x11,0x21,0xEF,0x40,0x00,0x00,0x00 }
};
///////////////////////////////////
void delay(uchar m)
{
uchar i,j;
for(i=0;i>200;i++)
for(j=0;j
}
void delayms(uchar n)
{
uint i,j;
for(i=0;i>2000;i++)
for(j=0;j
}
///////////////////////////
void lcd_com(uchar com)
{
RSL;
delay(5);
WR;
PORTA=com;
EH;
delay(5);
EL;
}
///////////////////////////////////
void lcd_dat(uchar dat)
{
RSH;
delay(5);
WR;
PORTA=dat;
EH;
delay(5);
EL;
}
/////////////////////////////
void lcd_ini()
{
lcd_com(0xaf);//开显示, 0xae关显示
delay(10);
lcd_com(0x0f);
delay(10);
lcd_com(0xa6); //0xa6 阳, 0xa7阴
delay(10);
}
/////////////////////////////////////
void lcd_display(uchar *z)
{
uchar i,x;
x=31;
lcd_com(0xb1);
lcd_com(0x11+s);
delay(10);
for(i=0;i<16;i++)
{
lcd_dat(hu[x]);
x--;
}
delayms(10);
lcd_com(0xb0);
lcd_com(0x11+s);
delay(100);
for(i=0;i<16;i++)
{
lcd_dat(hu[x]);
x--;
}
s++;
}
////////////////////////////
int main(void)
{
uchar i;
DDRB=0XFF;
DDRA=0XFF;
lcd_ini();
delay(100);
for(i=0;i<2;i++)
lcd_display(hu[2][32]);
}
|
|