資源描述:
《燈彩色旋轉(zhuǎn)led文字顯示程序》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、#include"NEW_8051.H"#defineucharunsignedchar#defineuintunsignedint//宏定義sbitR1=P6^6;//定義R每個IO控制的LEDsbitR2=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;sbit
2、R15=P3^4;sbitR16=P4^4;sbitG1=P2^1;//定義G每個IO控制的LEsbitG2=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控制的LEDs
3、bitB2=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;#defineucNumRows10
4、0//定義一周顯示列數(shù)/***************************************/voidShow_R(ucharr1,ucharr2)//數(shù)據(jù)輸出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=(
5、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)//數(shù)據(jù)輸出IO口G是綠色16燈{G1=(bit)(r1&0x01);G2=(bit)(r1&0x02);G3=(bit)(r1&0x04);G4=(bit)(r1&0x08);G5=(bit)(r1&0x10);
6、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)//數(shù)據(jù)輸出IO口B是綠色16燈{B1=(bit)(r1&0
7、x01);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);
8、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://藍(lán)色Show_