资源描述:
《3d光立方流动字母显示》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、//此图为侧面流动A,B,C,D,上面为I//亮度不够,闪烁太厉害,左侧反向#include#defineucharunsignedchar#defineuintunsignedintuintcodetableI[]={0x00,0x7E,0x18,0x18,0x18,0x18,0x7E,0x00,};uintcodetableA[]={0x00,0x18,0x24,0x42,0x7E,0x42,0x42,0x00,};uintcodetableB[]={0x00,0x38,0x24,0x
2、24,0x38,0x24,0x38,0x00,};uintcodetableC[]={0x00,0x1C,0x20,0x20,0x20,0x20,0x1C,0x00};uintcodetableD[]={0x00,0x38,0x24,0x24,0x24,0x24,0x38,0x00,};uintcodetableO[]={0x00,0x18,0x24,0x24,0x24,0x24,0x18,0x00,};voidLED1(uint*I);voidLED2(uint*a);voidLED3(uint*b);vo
3、idLED4(uint*c);voidLED5(uint*d);voidLED6(uint*o);voiddelayms(uintz){uintx,y;for(x=z;x>0;x--)for(y=55;y>0;y--);}voidmain(){//P2=0xff;//P0=0x00;//P2=0x00;while(1){uinti;i=50;while(--i){LED1(tableI);LED2(tableA);LED3(tableB);LED4(tableC);LED5(tableD);LED6(tabl
4、eO);}i=50;while(--i){LED1(tableI);LED2(tableB);LED3(tableC);LED4(tableD);LED5(tableA);LED6(tableO);}i=50;while(--i){LED1(tableI);LED2(tableC);LED3(tableD);LED4(tableA);LED5(tableB);LED6(tableO);}i=50;while(--i){LED1(tableI);LED2(tableD);LED3(tableA);LED4(ta
5、bleB);LED5(tableC);LED6(tableO);}}}//上面voidLED1(uint*I){uinti,temp;P2=0xff;P0=0x00;P2=0x00;P1=0x80;temp=0x01;for(i=0;i<8;i++){P2=temp;P0=I[i];delayms(1);P2=0x00;P2=0xff;P0=0x00;P2=0x00;temp<<=1;}}//后面voidLED2(uint*a){uinti,temp1;P2=0xff;P0=0x00;P2=0x00;temp
6、1=0x80;for(i=0;i<8;i++){P1=temp1;P2=0x80;P0=a[i];delayms(1);P2=0x00;P2=0xff;P0=0x00;P2=0x00;temp1>>=1;}}//右面voidLED3(uint*b){uinti,temp2;P2=0xff;P0=0x00;P2=0x00;temp2=0x80;for(i=0;i<8;i++){P1=temp2;P2=0x01;P0=b[i];delayms(1);P2=0x00;P2=0xff;P0=0x00;P2=0x00;
7、temp2>>=1;}}//前面voidLED4(uint*c){uinti,temp3;P2=0xff;P0=0x00;P2=0x00;temp3=0x80;for(i=0;i<8;i++){P1=temp3;P2=c[i];P0=0x01;delayms(1);P2=0x00;P2=0xff;P0=0x00;P2=0x00;temp3>>=1;}}//左面voidLED5(uint*d){uinti,temp4;P2=0xff;P0=0x00;P2=0x00;temp4=0x80;for(i=0;i<8;
8、i++){P1=temp4;P2=d[i];P0=0x80;delayms(1);P2=0x00;P2=0xff;P0=0x00;P2=0x00;temp4>>=1;}}//下面voidLED6(uint*o){uinti,temp5;P2=0xff;P0=0x00;P2=0x00;P1=0x01;temp5=0x80;for(i=0;i<8;i++){P2=temp5;P0=o[i];delaym