灯彩色旋转LED文字显示程序.docx
- 文档编号:11424717
- 上传时间:2023-03-01
- 格式:DOCX
- 页数:17
- 大小:17.79KB
灯彩色旋转LED文字显示程序.docx
《灯彩色旋转LED文字显示程序.docx》由会员分享,可在线阅读,更多相关《灯彩色旋转LED文字显示程序.docx(17页珍藏版)》请在冰豆网上搜索。
灯彩色旋转LED文字显示程序
#include"NEW_8051.H"
#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;
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;
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;
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;
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//定义一周显示列数
/***************************************/
voidShow_R(ucharr1,ucharr2)//数据输出IO口R是红色16灯
{
R1=(bit)(r1&0x01);
R2=(bit)(r1&0x02);
R3=(bit)(r1&0x04);
R4=(bit)(r1&0x08);
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);
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);
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);
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);
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);
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)
{
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);
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;
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--);
}
/*********中断子程序**********/
voidint0()interrupt0//使用外部中断0
{
BIT_timeout=1;//起点标志位
}
/*****主函数*****/
voidmain(void)
{
P1M0=0X00;
P1M1=0X00;
P0M0=0X00;//IO口初始化准双向IO
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;
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不再流水测试
j++;
if(j>688)//显示完文字后循环;j=16*需要显示的字数768/16=48宽24X32高大字j=24*显示的字数768/24=32
{
j=0;
}
for(i=j;i { Show_Color(zimo[i*2],zimo[i*2+1],(i/16)%7);//送16X16字显示 Delay15us();//延时一段时间 if(BIT_timeout==1)//这里如果没有显示完一圈的数据回到起点了 //直接跳出就不会出现头吃尾的现象而且盲点很小 { return; } } Show_Color(0xFF,0XFF,7); } } } //PC2002字幕软件配置(逐列阳码逆向)字大小16X16 ucharcodezimo[]={ 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,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xBB,0xAB,0xBB,0x9B,0xBB,0xBB,0xAB,0xBF,0xF3,0xBF,0xFF,0xFF,/*"宝",31*/ 0xFF,0x7F,0xEF,0xBF,0xEF,0xDF,0xEF,0xE7,0xEF,0xF8,0x00,0xFF,0xEF,0xFF,0xEF,0xFF, 0xEF,0xFF,0xEF,0xFF,0x0F,0xC0,0xFF,0xBF,0xFF,0xBF,0xFF,0xBF,0xFF,0x87,0xFF,0xFF,/*"九",32*/ 0x7F,0xFF,0x7D,0xFF,0x7D,0xFF,0x7D,0xFF,0x7D,0xFF,0x7D,0xBF,0x7D,0x7F,0x1D,0x80, 0x5D,0xFF,0x6D,0xFF,0x75,0xFF,0x79,0xFF,0x7D,0xFF,0x7F,0xFF,0x7F,0xFF,0xFF,0xFF,/*"子",33*/
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 灯彩 旋转 LED 文字 显示 程序