//其中的595前面有,这里就不再啰嗦
#ifndef __LCD1602_H__
#define __LCD1602_H__
#include "yiwei595.h"
#define lcden_out P2DIR|=BIT2
#define lcden_in P2DIR&=~BIT2
#define lcden_h P2OUT|=BIT2
#define lcden_l P2OUT&=~BIT2
#define rw_out P2DIR|=BIT1
#define rw_in P2DIR&=~BIT1
#define rw_h P2OUT|=BIT1
#define rw_l P2OUT&=~BIT1
#define rs_out P2DIR|=BIT0
#define rs_in P2DIR&=~BIT0
#define rs_h P2OUT|=BIT0
#define rs_l P2OUT&=~BIT0
void write_com(uchar com)
{
lcden_out;
rs_out;
rw_out;
rs_l;
rw_l;
lcden_l;
input_595(com);
delay(1);
lcden_h;
delay(1);
lcden_l;
}
void write_date(uchar date)
{
lcden_out;
rs_out;
rs_h;
rw_l;
lcden_l;
input_595(date);
delay(1);
lcden_h;
delay(1);
lcden_l;
}
void display_string(uchar *p,uchar com)
{
uchar i;
write_com(com);
for(i=0;i<16;i++)
{
write_date(p);
}
}
void init_lcd()
{
lcden_out;
lcden_l;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
display_string(" welcome ",0x80);
display_string("san xia xue yuan",0xc0);
}
#endif