芯片复制单片机+ET2046+LCD1602继电器源程序
芯片复制#include <reg52.h>
芯片复制#include <intrins.h>
芯片复制#define uint unsigned int
芯片复制#define uchar unsigned char
sbit RS = P2^6;
sbit RW = P2^5;
sbit EN = P2^7;
sbit DCLK = P3^6;
sbit DIN = P3^4;
sbit CS = P3^5;
sbit DOUT = P3^7;
uint disp[4];
void delayms(uint xms)
{
int i,j;
for(i=xms;i>0;i--)
for(j=114;j>0;j--);
}
void write_com(int com)
{
EN = 0;
RS = 0;
RW = 0;
P0 = com;
delayms(1);
EN = 1;
delayms(5);
EN = 0;
}
void write_date(int date)
{
EN = 0;
RS = 1;
RW = 0;
P0 = date;
delayms(1);
EN = 1;
delayms(5);
EN = 0;
}
void lcdset()
{
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void display()
{
write_com(0x80);
write_date((disp[0])+'0');
write_com(0x81);
write_date((disp[1])+'0');
write_com(0x82);
write_date((disp[2])+'0');
write_com(0x83);
write_date((disp[3])+'0');
}
void SPI_Write(uchar dat)
{
uchar i;
DCLK = 0;
for(i=0; i<8; i++)
{
DIN = dat >> 7;
dat <<= 1;
DCLK = 0;
DCLK = 1;
}
}

芯片解密