|
玩幾種花樣,效果動畫待周一后補充
#include "REG52.h"
sbit ds=P1^0; // 數(shù)據(jù)線 595的14腳
sbit shcp=P1^1; // 數(shù)據(jù)輸入時鐘線 595的11腳
sbit shcp=P1^2; // 輸出存儲器鎖存時鐘線 595的12腳
sbit mr=P1^3; // 數(shù)據(jù)清零
unsigned char code shuju[]={0x00,0x38,0x38,0x38,0xfe,0x7c,0x38,0x10}; // LED點陣高電平端口數(shù)據(jù)
unsigned char code shuju[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; // LED點陣低電平端口位
void QuDong595(unsigned char sj)
{
unsigned char aa=8;
mr=0;mr=1;
while(aa--)
{
ds=sj>>7;
sj<<=1; // 十六進制數(shù)據(jù)發(fā)送
shcp=1; // 上升沿發(fā)生移位 上升沿時數(shù)據(jù)寄存器的數(shù)據(jù)鎖存。
shcp=0;
}
stcp=0;
stcp=1; // 上升沿將數(shù)據(jù)送到輸出鎖存器
stcp=0;
}
void main()
{
unsigned char Xd=0,ss=1,cs=0,d=0,y=0;
unsigned int ys=0;
// ZhongDuonSheZhi();
while(1)
{
P0=dzwei[7-cs]; // 控制圖形方向數(shù)據(jù)出現(xiàn) ((cs+d)<8?shuju[cs+d]:0x00)
QuDong595(((cs+d)<8?shuju[cs+d]:0x00)); // 數(shù)據(jù)消失cs+d倒退 7-cs前進
// QuDong595(((cs+8-d)<8?shuju[cs+8-d]:0x00)); //數(shù)據(jù)消失cs+d 7-cs前進
// P0=~((cs+d)<8?shuju[(7-cs)-d]:0x00);QuDong595(~dzwei[7-cs]); // 90°轉(zhuǎn)向
while(++Xd);mr=0;mr=1;QuDong595(0x00);
if(++cs>7)cs=0;
if(++y==0){if(++d>8*1)d=0;}
}
}
============================ |
|