資源描述:
《16燈彩色旋轉(zhuǎn)LED文字顯示程序.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、#include"NEW_8051.H"#defineucharunsignedchar#defineuintunsignedint//宏定義sbitR1=P6^6;//定義R每個(gè)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;sbitR15=P3^4;sbitR16=P4^4;s
2、bitG1=P2^1;//定義G每個(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每個(gè)IO控制的LEDsbitB2=P2^0;sbitB3=P2^5;sbitB4=P7^5;sbitB5=P5^5
3、;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//定義一周顯示列數(shù)/***************************************/voidShow_R(ucharr
4、1,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=(bit)(r2&0x02);R11=(bit)(r2&0x04);R12=(bit)(r2&0x08);R13=(bit)(r2&0x10);R14=(bit)(r2&0x20);R1
5、5=(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);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=(
6、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&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
7、)(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://藍(lán)色Show_