开始的时候总是比较难,因为看不到东西,接口时序不对就没办法.帮你找了一个是51的,能看到东西就好办了.
///*****************************************
////PS176220T-022-L-07
/// LCD:60228
//IC:R61503B
//PROGRAMMER:STRONG
//DATE:2006/11/29
//******************************************
#include
#include
sbit RDB =P3^4;
sbit WRB = P3^3;
sbit A0 = P3^2;
sbit RESB = P3^0;
sbit CSB = P3^1;
sbit AUTOB= P3^6;
sbit STEPB =P3^7;
sbit BL =P2^7;
void initial_main(void);
void delayms(int);
void red(void);
void green(void);
void blue(void);
void white(void);
void black(void);
void gray(void);
void picture(void);
void RGB(void);
void write_comm(int);
void write_data(int);
void press(void);
//void BLED(void);
void main()
{
RESB=0;
//delayms(5);
RESB=1;
// BLED() ;
initial_main();
while(1)
{
picture();//picutre
delayms(10);
press();
red();///?┏厚?
delayms(10);
press();
green();//厚┏屡?
delayms(10);
press();
blue();//屡┏??
delayms(10);
press();
white();//フ┏堵?
delayms(10);
press();
black();//堵┏フ?
delayms(10);
press();
gray();///gray scale
delayms(10);
press();
RGB();//RGB
delayms(10);
press();
}
}
void initial_main(void)
{
write_comm(0x00);
write_data(0x00);write_data(0x00);
write_comm(0x00);
write_data(0x00);write_data(0x00);
write_comm(0x00);
write_data(0x00);write_data(0x00);
write_comm(0x00);
write_data(0x00);write_data(0x00);
write_comm(0x00);
write_data(0x00); write_data(0x01);
delayms(10);
write_comm(0xA4);
write_data(0x00);write_data(0x01);
delayms(30);
write_comm(0x07);
write_data(0x00);write_data(0x01);
write_comm(0x18);
write_data(0x00);write_data(0x01);
write_comm(0x10);
write_data(0x15);write_data(0xB0);
write_comm(0x11);
write_data(0x00); write_data(0x07);
write_comm(0x12);
write_data(0x01);write_data(0x12);
write_comm(0x13);
write_data(0x87);write_data(0x0E);
write_comm(0x14);
write_data(0x80);write_data(0x00);
write_comm(0x12);
write_data(0x01); write_data(0x32);
delayms(10);
write_comm(0x01);
write_data(0x01);write_data(0x00);
write_comm(0x02);
write_data(0x07);write_data(0x00);
write_comm(0x03);
write_data(0x10);write_data(0x30);
write_comm(0x04);
write_data(0x00);write_data(0x00);
write_comm(0x08);
write_data(0x07);write_data(0x08);
write_comm(0x09);
write_data(0x00);write_data(0x00);
write_comm(0x0C);
write_data(0x00);write_data(0x00);
write_comm(0x0F);
write_data(0x00);write_data(0x00);
write_comm(0x20);
write_data(0x00);write_data(0x00);
write_comm(0x21);
write_data(0x00);write_data(0x00);
write_comm(0x28);
write_data(0x00);write_data(0x00);
write_comm(0x29);
write_data(0x00);write_data(0x00);
write_comm(0x2A);
write_data(0x00);write_data(0x00);
write_comm(0x30);
write_data(0x04);write_data(0x00);
write_comm(0x31);
write_data(0x00);write_data(0x02);
write_comm(0x32);
write_data(0x00);write_data(0x00);
write_comm(0x33);
write_data(0x07);write_data(0x01);
write_comm(0x34);
write_data(0x07);write_data(0x07);
write_comm(0x35);
write_data(0x05);write_data(0x07);
write_comm(0x36);
write_data(0x07);write_data(0x07);
write_comm(0x37);
write_data(0x04);write_data(0x02);
write_comm(0x38);
write_data(0x07);write_data(0x00);
write_comm(0x39);
write_data(0x06);write_data(0x02);
write_comm(0x3A);
write_data(0x02);write_data(0x00);
write_comm(0x20);
write_data(0x00);write_data(0x00);
write_comm(0x21);
write_data(0x00); write_data(0x00);
write_comm(0x50);
write_data(0x00);write_data(0x00);
write_comm(0x51);
write_data(0x00);write_data(0xAF);
write_comm(0x52);
write_data(0x00);write_data(0x00);
write_comm(0x53);
write_data(0x00);write_data(0xDB);
write_comm(0x70);
write_data(0x9B);write_data(0x00);
write_comm(0x71);
write_data(0x00);write_data(0x01);
write_comm(0x7A);
write_data(0x00); write_data(0x00);
write_comm(0x80);
write_data(0x00);write_data(0x00);
write_comm(0x81);
write_data(0x00);write_data(0x00);
write_comm(0x82);
write_data(0x00);write_data(0x00);
write_comm(0x83);
write_data(0x00);write_data(0x00);
write_comm(0x84);
write_data(0x00);write_data(0x00);
write_comm(0x85);
write_data(0x00);write_data(0x00);
write_comm(0x90);
write_data(0x00); write_data(0x00);
write_comm(0x91);
write_data(0x01); write_data(0x00);
write_comm(0x92);
write_data(0x00);write_data(0x01);
write_comm(0x93);
write_data(0x00);write_data(0x00);
write_comm(0x94);
write_data(0x00);write_data(0x00);
write_comm(0x95);
write_data(0x00);write_data(0x00);
write_comm(0x98);
write_data(0x00);write_data(0x00);
write_comm(0x99);
write_data(0x05);write_data(0x0A);
write_comm(0x9A);
write_data(0x05); write_data(0x0A);
write_comm(0x9B);
write_data(0x00);write_data(0x00);
write_comm(0x9C);
write_data(0x00);write_data(0x00);
write_comm(0xA0);
write_data(0x00);write_data(0x00);
write_comm(0xA1);
write_data(0x00);write_data(0x00);
write_comm(0x07);
write_data(0x00); write_data(0x00);
delayms(10);
write_comm(0x07);
write_data(0x00);write_data(0x21);
delayms(1);
write_comm(0x12);
write_data(0x11); write_data(0x32);
delayms(10);
write_comm(0x07);
write_data(0x02);write_data(0x33);
write_comm(0x22);
}
void write_comm(int DPL)
{
A0=0;
CSB=0;
P1=0X00;
WRB=0;
WRB=1;
CSB=1;
CSB=0;
P1=DPL;
WRB=0;
WRB=1;
CSB=1;
}
void write_data(int DPL)
{
A0=1;
CSB=0;
P1=DPL;
WRB=0;
WRB=1;
CSB=1;
}
void delayms(int count)
{int i,j;
for(i=0;i
for(j=0;j<5000;j++);
}
void press(void)
{
while(AUTOB == 0)
{
if(STEPB == 0)
{ goto aas;
}
else
{ if(AUTOB == 1)
goto aas;
}
}
aas: ;
}
void red(void)//?┏厚?
{int i,j;
/*
write_comm(0x21);
write_data(0x00);
write_data(0x00);
write_comm(0x22);
*/
for(i=0;i<176;i++)
{
write_data(0x07);
write_data(0xe0);
}
for(j=0;j<218;j++)
{
write_data(0x07);
write_data(0xe0);
for(i=0;i<174;i++)
{
write_data(0xf8);
write_data(0x00);
}
write_data(0x07);
write_data(0xe0);
}
for(i=0;i<176;i++)
{
write_data(0x07);
write_data(0xe0);
}
}
void green(void)//厚┏屡?
{int i,j;
/*
write_comm(0x21);
write_data(0x00);
write_data(0x00);
write_comm(0x22);
*/
for(i=0;i<176;i++)
{
write_data(0x00);
write_data(0x1f);
}
for(j=0;j<218;j++)
{
write_data(0x00);
write_data(0x1f);
for(i=0;i<174;i++)
{
write_data(0x07);
write_data(0xe0);
}
write_data(0x00);
write_data(0x1f);
}
for(i=0;i<176;i++)
{
write_data(0x00);
write_data(0x1f);
}
}
void blue(void)//屡┏??
{int i,j;
write_comm(0x21);
write_data(0x00);
write_data(0x00);
write_comm(0x22);
for(i=0;i<176;i++)
{
write_data(0xf8);
write_data(0x00);
}
for(j=0;j<218;j++)
{
write_data(0xf8);
write_data(0x00);
for(i=0;i<174;i++)
{
write_data(0x00);
write_data(0x1f);
}
write_data(0xf8);
write_data(0x00);
}
for(i=0;i<176;i++)
{
write_data(0xf8);
write_data(0x00);
}
}
void white(void) //フ┏堵?
{
int i,j;
write_comm(0x21);
write_data(0x00);
write_data(0x00);
write_comm(0x22);
for(i=0;i<176;i++)
{
write_data(0x00);
write_data(0x00);
}
for(j=0;j<218;j++)
{
write_data(0x00);
write_data(0x00);
for(i=0;i<174;i++)
{
write_data(0xff);
write_data(0xff);
}
write_data(0x00);
write_data(0x00);
}
for(i=0;i<176;i++)
{
write_data(0x00);
write_data(0x00);
}
}
void black(void) //堵┏フ?
{
int i,j;
write_comm(0x21);
write_data(0x00);
write_data(0x00);
write_comm(0x22);
for(i=0;i<176;i++)
{
write_data(0xff);
write_data(0xff);
}
for(j=0;j<218;j++)
{
write_data(0xff);
write_data(0xff);
for(i=0;i<174;i++)
{
write_data(0x00);
write_data(0x00);
}
write_data(0xff);
write_data(0xff);
}
for(i=0;i<176;i++)
{
write_data(0xff);
write_data(0xff);
}
}
void gray(void) //gray scal
{
int i,j;
write_comm(0x21);
write_data(0x00);
write_data(0x00);
write_comm(0x22);
for(j=0;j<110;j++)
{
for(i=0;i<11;i++)
{
write_data(0x00);// 1
write_data(0x00);
}
for(i=11;i<22;i++)
{
write_data(0x08);//2
write_data(0x61);
}
for(i=22;i<33;i++) //3
{
write_data(0x18);
write_data(0xe3);
}
for(i=33;i<44;i++) //4
{
write_data(0x29);
write_data(0x65);
}
for(i=44;i<55;i++) //5
{
write_data(0x39);
write_data(0xe7);
}
for(i=55;i<66;i++) //6
{
write_data(0x4a);
write_data(0x69);
}
for(i=66;i<77;i++) //7
{
write_data(0x5a);
write_data(0xeb);
}
for(i=77;i<88;i++) //8
{
write_data(0x6b);
write_data(0x6d);
}
for(i=88;i<99;i++) //9
{
write_data(0x7b);
write_data(0xef);
}
for(i=99;i<110;i++) //10
{
write_data(0x8c);
write_data(0x71);
}
for(i=110;i<121;i++)//11
{
write_data(0xad);
write_data(0x75);
}
for(i=121;i<132;i++)//12
{
write_data(0xbd);
write_data(0xf7);
}
for(i=132;i<143;i++) //13
{
write_data(0xce);
write_data(0x79);
}
for(i=143;i<154;i++) //14
{
write_data(0xde);
write_data(0xfb);
}
for(i=154;i<165;i++) //15
{
write_data(0xef);
write_data(0x7f);
}
for(i=165;i<176;i++) //16
{
write_data(0xff);
write_data(0xff);
}
}
for(j=110;j<220;j++)
{
for(i=0;i<88;i++)
{
write_data(0xff);
write_data(0xff);
}
for(i=88;i<176;i++)
{
write_data(0x00);
write_data(0x00);
}
}
}
void picture(void) //
{
int i,j,x,y;
write_comm(0x21); //
write_data(0x00);
write_data(0x00);
write_comm(0x22);
for(i=0;i<176;i++)
for(j=0;j<20;j++)
{
write_data(0x00);
write_data(0x00);
}
x=0;
y=1;
for(j=0;j<180;j++)
{
for(i=0;i<13;i++)
{
write_data(0x00);
write_data(0x00);
}
for(i=0;i<150;i++)
{
write_data(pic[x]);
write_data(pic[y]);
x=x+2;
y=y+2;
}
for(i=0;i<13;i++)
{
write_data(0x00);
write_data(0x00);
}
}
for(i=0;i<176;i++)
for(j=0;j<20;j++)
{
write_data(0x00);
write_data(0x00);
}
}
void RGB(void)//RGB
{
int i,j;
write_comm(0x21);
write_data(0x00);
write_data(0x000);
write_comm(0x22);
for(j=0;j<220;j++)
{
for(i=0;i<22;i++)
{
write_data(0xf8);
write_data(0x00);
}
for(i=0;i<22;i++)
{
write_data(0x07);
write_data(0xe0);
}
for(i=0;i<22;i++)
{
write_data(0x00);
write_data(0x1f);
}
for(i=0;i<22;i++)
{
write_data(0xf8);
write_data(0x00);
}
for(i=0;i<22;i++)
{
write_data(0x07);
write_data(0xe0);
}
for(i=0;i<22;i++)
{
write_data(0x00);
write_data(0x1f);
}
for(i=0;i<22;i++)
{
write_data(0xf8);
write_data(0x00);
}
for(i=0;i<22;i++)
{
write_data(0x07);
write_data(0xe0);
}
}
}