灯彩色旋转LED文字显示程序

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
P3=0XFF;
P4=0XFF;
P5=0XFF;
P6=0XFF;
P7=0XFF;
IT0=1;//初始化外部中断起点检测
EX0=1;
EA=1;//开中断
//主程序中
while(1)
{
if(BIT_timeout==1)//起点判断
{
BIT_timeout=0;//清零
//Scan_bit=1;//起点检测到后LED不再流水测试
0xFF,0xFF,0x07,0xF0,0xF7,0xFF,0x00,0x00,0xF7,0xF7,0x07,0x70,0xFF,0x9F,0x01,0xE0,
0xBD,0xFF,0x7D,0xFE,0xFD,0xFF,0x01,0xC0,0xFF,0xBF,0xFF,0xBF,0xFF,0x87,0xFF,0xFF,/*"帆",1*/
0xEF,0x7F,0xEF,0xBF,0xEF,0xDF,0xEF,0xE7,0xEF,0xF9,0x00,0xBE,0xEF,0xDF,0xEF,0xEF,
0x0F,0xC0,0xEF,0xBB,0xEE,0xBD,0xE9,0xBE,0x2F,0xBF,0xEF,0xBF,0xEF,0x87,0xFF,0xFF,/*"龙",6*/
0xFF,0x7F,0x01,0x80,0xDD,0xFD,0xDD,0x7D,0x01,0x00,0xD7,0xFE,0x56,0xDF,0x91,0xD2,
0xD7,0xD6,0xC0,0xD6,0xD7,0xD6,0x93,0xB0,0x54,0x77,0xD7,0x86,0xDF,0xFE,0xFF,0xFF,/*"腾",7*/
sbitB12=P0^3;
sbitB13=P5^4;
sbitB14=P2^4;
sbitB15=P7^4;
sbitB16=P5^0;
ucharcodezimo[];
bitScan_bit=0;
bitBIT_timeout=0;
uinti=0,j=0;
#defineucNumRows100//定义一周显示列数
0xFF,0xBF,0x01,0xC0,0xFF,0xFF,0x03,0xC0,0xFF,0xFF,0x00,0x00,0xFF,0x7F,0x0D,0xB0,
0xED,0xDF,0xE5,0xE7,0x29,0xF8,0xED,0xEF,0xED,0xDF,0x0D,0xB0,0xFD,0x7F,0xFF,0xFF,/*"顺",3*/
sbitG3=P6^4;
sbitG4=P7^7;
sbitG5=P4^6;
sbitG6=P0^2;
sbitG7=P6^1;
sbitG8=P1^4;
sbitG9=P1^6;
sbitG10=P4^7;
sbitG11=P6^0;
sbitG12=P5^2;
sbitG13=P4^5;
sbitG14=P2^6;
sbitG15=P6^7;
G13=(bit)(r2&0x10);
G14=(bit)(r2&0x20);
G15=(bit)(r2&0x40);
G16=(bit)(r2&0x80);
}
voidShow_B(ucharr1,ucharr2)//数据输出IO口B是绿色16灯
{
B1=(bit)(r1&0x01);
B2=(bit)(r1&0x02);
{
case0://红色
Show_R(r1,r2);
break;
case1://绿色
Show_G(r1,r2);
break;
case2://蓝色
Show_B(r1,r2);
break;
case3://黄色
Show_R(r1,r2);
Show_G(r1,r2);
break;
case4://紫色
Show_R(r1,r2);
#defineucharunsignedchar
#defineuintunsignedint//宏定义
sbitR1=P6^6;//定义R每个IO控制的LED
sbitR2=P2^7;
sbitR3=P4^0;
sbitR4=P1^7;
sbitR5=P0^0;
sbitR6=P0^6;
sbitR7=P1^2;
Delay15us();//延时一段时间
if(BIT_timeout==1)//这里如果没有显示完一圈的数据回到起点了
//直接跳出就不会出现头吃尾的现象而且盲点很小
{
return;
}
}
Show_Color(0xFF,0XFF,7);
}
}
}
//PC2002字幕软件配置(逐列阳码逆向)字大小16X16
ucharcodezimo[]={
/*********中断子程序**********/
voidint0()interrupt0//使用外部中断0
{
BIT_timeout=1;//起点标志位
}
/*****主函数*****/
voidmain(void)
{
P1M0=0X00;
P1M1=0X00;
P0M0=0X00;//IO口初始化准双向IO
B12=(bit)(r2&0x08);
B13=(bit)(r2&0x10);
B14=(bit)(r2&0x20);
B15=(bit)(r2&0x40);
B16=(bit)(r2&0x80);
}
voidShow_Color(ucharr1,ucharr2,ucharcolor)//显示7彩色
{
switch(color)
0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,
0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0xFF,0xFF,/*"一",0*/
0xFF,0xF7,0xF7,0xF7,0x77,0xF7,0x77,0xF7,0x76,0xF7,0x71,0xF7,0x77,0xF7,0x07,0x00,
0x77,0xF7,0x73,0xF7,0x74,0xF7,0x77,0xF7,0x77,0xF7,0xF7,0xF7,0xFF,0xF7,0xFF,0xFF,/*"羊",9*/
Show_B(r1,r2);
break;
case5://青色
Show_G(r1,r2);
Show_B(r1,r2);
break;
case6://白色
Show_R(r1,r2);
Show_G(r1,r2);
Show_B(r1,r2);
break;
default:
P0=0XFF;
P1=0XFF;
P2=0XFF;
P0M1=0X00;
P2M0=0X00;
P2M1=0X00;
P3M0=0X00;
P3M1=0X00;
P4M0=0X00;
P4M1=0X00;
P5M0=0X00;
P5M1=0X00;
P6M0=0X00;
P6M1=0X00;
P7M0=0X00;
P7M1=0X00;
P0=0XFF;
P1=0XFF;
P2=0XFF;
B3=(bit)(r1&0x04);
B4=(bit)(r1&0x08);
B5=(bit)(r1&0x10);
B6=(bit)(r1&0x20);
B7=(bit)(r1&0x40);
B8=(bit)(r1&0x80);
B9=(bit)(r2&0x01);
B10=(bit)(r2&0x02);
B11=(bit)(r2&0x04);
R5=(bit)(r1&0x10);
R6=(bit)(r1&0x20);
R7=(bit)(r1&0x40);
R8=(bit)(r1&0x80);
R9=(bit)(r2&0x01);
R10=(bit)(r2&0x02);
R11=(bit)(r2&0x04);
R12=(bit)(r2&0x08);
R13=(bit)(r2&0x10);
0xDF,0xFF,0xDF,0xFF,0xDF,0xFF,0x01,0x80,0xDF,0xBF,0xDF,0xBF,0x00,0xB8,0xDF,0xBB,
0xDF,0xBB,0xDF,0xBB,0x00,0xB8,0xDF,0xBF,0xDF,0xBF,0xDF,0xBF,0xDF,0xFF,0xFF,0xFF,/*"世",5*/
j++;
if(j>688)//显示完文字后循环;j=16*需要显示的字数768/16=48宽24X32高大字j=24*显示的字数768/24=32
{
j=0;
}
for(i=j;i<ucNumRows+wenku.baidu.com;i++)//显示190列数据
{
Show_Color(zimo[i*2],zimo[i*2+1],(i/16)%7);//送16X16字显示
0xFF,0xEF,0xFF,0xEF,0xF7,0xEF,0xF7,0xEF,0xF7,0xEF,0xF7,0xEF,0xF7,0xEF,0xF7,0xEF,
0xF7,0xEF,0xF7,0xEF,0xF7,0xEF,0xF7,0xEF,0xF7,0xEF,0xFF,0xEF,0xFF,0xEF,0xFF,0xFF,/*"二",4*/
sbitR8=P1^5;
sbitR9=P1^1;
sbitR10=P0^7;
sbitR11=P0^5;
sbitR12=P0^1;
sbitR13=P7^6;
sbitR14=P6^5;
sbitR15=P3^4;
sbitR16=P4^4;
sbitG1=P2^1;//定义G每个IO控制的LE
sbitG2=P2^3;
0xFF,0x7F,0xFF,0x9F,0x01,0xE0,0xFD,0xFF,0xED,0xDF,0xDD,0xEF,0x3D,0xF3,0xFD,0xFC,
0x3D,0xF3,0xCD,0xCF,0xFD,0xFF,0x01,0xF0,0xFF,0xCF,0xFF,0xBF,0xFF,0x07,0xFF,0xFF,/*"风",2*/
0x7F,0xFF,0x7D,0x7F,0x7D,0xBF,0x7D,0xCF,0x01,0xF0,0x7D,0xFF,0x7D,0xFF,0x7D,0xFF,
0x7D,0xFF,0x7D,0xFF,0x01,0x00,0x7D,0xFF,0x7D,0xFF,0x7D,0xFF,0x7F,0xFF,0xFF,0xFF,/*"开",10*/
/***************************************/
voidShow_R(ucharr1,ucharr2)//数据输出IO口R是红色16灯
{
R1=(bit)(r1&0x01);
R2=(bit)(r1&0x02);
R3=(bit)(r1&0x04);
R4=(bit)(r1&0x08);
P3=0XFF;
P4=0XFF;
P5=0XFF;
P6=0XFF;
P7=0XFF;
break;
}
}
/*****n(us)延时子程序*****/
voidDelay15us()//@18.432MHz
{
unsignedchara,b;
for(b=140;b>0;b--)
for(a=5;a>0;a--);
}
R14=(bit)(r2&0x20);
R15=(bit)(r2&0x40);
R16=(bit)(r2&0x80);
}
voidShow_G(ucharr1,ucharr2)//数据输出IO口G是绿色16灯
{
G1=(bit)(r1&0x01);
G2=(bit)(r1&0x02);
G3=(bit)(r1&0x04);
sbitG16=P2^2;
sbitB1=P4^3;//定义B每个IO控制的LED
sbitB2=P2^0;
sbitB3=P2^5;
sbitB4=P7^5;
sbitB5=P5^5;
sbitB6=P0^4;
sbitB7=P5^3;
sbitB8=P6^3;
sbitB9=P1^3;
sbitB10=P1^0;
sbitB11=P6^2;
0xFF,0xDF,0xFB,0xDF,0x7B,0xDF,0x7B,0xDF,0x7B,0xDF,0x7B,0xDF,0x7B,0xDF,0x7B,0xDF,
0x7B,0xDF,0x7B,0xDF,0x7B,0xDF,0x7B,0xDF,0x7B,0xDF,0xFB,0xDF,0xFF,0xDF,0xFF,0xFF,/*"三",8*/
G4=(bit)(r1&0x08);
G5=(bit)(r1&0x10);
G6=(bit)(r1&0x20);
G7=(bit)(r1&0x40);
G8=(bit)(r1&0x80);
G9=(bit)(r2&0x01);
G10=(bit)(r2&0x02);
G11=(bit)(r2&0x04);
G12=(bit)(r2&0x08);
相关文档
最新文档