心形流水灯程序

合集下载

心形花样LED流水灯程序

心形花样LED流水灯程序

/*心形花样LED 流水灯程序*/#include<reg52.h>#include <intrins.h>#define uint unsigned int#define uchar unsigned charuchar code table[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00}; // 逐个点亮0~7uchar code table1[]={0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00}; // 逐个点亮7~0 uchar code table2[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff}; // 逐个灭0~7uchar code table3[]={0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff}; // 逐个灭7~0/***********************************************************/void delay(uint t); //延时void zg(uint t,uchar a);//两边逐个亮void qs(uint t,uchar a);//全部闪烁void zgxh(uint t,uchar a); // 逆时针逐个点亮//void zgxh1(uint t,uchar a); // 顺时针逐个点亮void djs(uint t,uchar a); //对角闪void lbzgm(uint t,uchar a);//两边逐个灭//void sszgm(uint t,uchar a); // 顺时针逐个灭void nszgm(uint t,uchar a); // 逆时针逐个灭void sztl(uint t,uchar a);//顺时逐个同步亮void nztl(uint t,uchar a);//逆时逐个同步亮void sztm(uint t,uchar a);//顺时逐个同步灭void nztm(uint t,uchar a);//逆时逐个同步灭void hwzjl(uint t,uchar a); //横往中间亮void hwzjm(uint t,uchar a); //横往中间灭//void swzjl(uint t,uchar a); //竖往中间亮//void swzjm(uint t,uchar a); //竖往中间灭void nzdl(uint t,uchar a); //逆时逐段亮void nzdgl(uint t,uchar a); //逆时逐段一个点亮void jgs(uint t,uchar a); //间隔闪/**********************************************************/void zg(uint t,uchar a)//两边逐个亮{uchar i,j;for(j=0;j<a;j++){P0=P1=P2=P3=0xff;P0=0x7f;delay(t);for(i=0;i<7;i++)P0=table1[i+1];P2=table1[i];delay(t);}P2=0x00;P1=0xfe;delay(t);for(i=0;i<7;i++){P1=table[i+1];P3=table1[i];delay(t);}P3=0x00;delay(t);}}void qs(uint t,uchar a) //全部闪烁{uchar j;for(j=0;j<a;j++){P0=P1=P2=P3=0xff;delay(t);P0=P1=P2=P3=0x00;delay(t);}}void zgxh(uint t,uchar a) // 逆时针逐个点亮{uchar i,j;for (j=0;j<a;j++){P0=P1=P2=P3=0xff;for (i=0;i<8;i++){P0=table1[i];delay(t);for(i=0;i<8;i++){P1=table[i];delay(t);}for(i=0;i<8;i++){P3=table[i];delay(t);}for(i=0;i<8;i++){P2=table[i];delay(t);}}}void nszgm(uint t,uchar a) // 逆时针逐个灭{uchar i,j;for(j=0;j<a;j++){P0=P1=P2=P3=0x00;for (i=0;i<8;i++){P0=table3[i];delay(t);}for (i=0;i<8;i++){P1=table2[i];delay(t);}for (i=0;i<8;i++){P3=table2[i];delay(t);}for (i=0;i<8;i++){P2=table2[i];delay(t);}}}/*void zgxh1(uint t,uchar a) // 顺时针逐个点亮{uchar i,j;for (j=0;j<a;j++){P0=P1=P2=P3=0xff;for (i=0;i<8;i++){P2=table1[i];delay(t);}for(i=0;i<8;i++){P3=table1[i];delay(t);}for(i=0;i<8;i++){P1=table1[i];delay(t);}for(i=0;i<8;i++){P0=table[i];delay(t);}}}*//*void sszgm(uint t,uchar a) // 顺时针逐个灭{uchar i,j;for(j=0;j<a;j++){P0=P1=P2=P3=0x00;for (i=0;i<8;i++){P2=table3[i];delay(t);}for (i=0;i<8;i++){P3=table3[i];delay(t);}for (i=0;i<8;i++){P1=table3[i];delay(t);}for (i=0;i<8;i++){P0=table2[i];delay(t);}}}*/void djs(uint t,uchar a) //对角闪{uchar j;for(j=0;j<a;j++){P0=P1=P2=P3=0xff;P0=P3=0x00;delay(t);P0=P1=P2=P3=0xff;P1=P2=0x00;delay(t);}}void lbzgm(uint t,uchar a)//两边逐个灭{uchar i,j;for (j=0;j<a;j++){P0=P2=0x00;P3=0x01;delay(t);for(i=7;i>1;i--){P1=table[i-1];P3=table1[i-2];delay(t);}P1=0xfe;P3=0xff;delay(t);P1=0xff;P2=0x01;delay(t);for(i=7;i>1;i--){P0=table1[i-1];P2=table1[i-2];delay(t);}P0=0x7f;P2=0xff;delay(t);P0=0xff;delay(t);}}void sztl(uint t,uchar a)//顺时逐个同步亮{uchar i,j;for(j=0;j<a;j++){P0=P1=P2=P3=0xff;for(i=0;i<8;i++){P0=table[i];P1=P2=P3=table1[i];delay(t);}}}void nztl(uint t,uchar a)//逆时逐个同步亮{uchar i,j;for(j=0;j<a;j++){P0=P1=P2=P3=0xff;for(i=0;i<8;i++){P0=table1[i];P1=P2=P3=table[i];delay(t);}}}void sztm(uint t,uchar a)//顺时逐个同步灭{uchar i,j;for(j=0;j<a;j++){P0=P1=P2=P3=0x00;for(i=0;i<8;i++){P0=table2[i];P1=P2=P3=table3[i];delay(t);}}}void nztm(uint t,uchar a)//逆时逐个同步灭{uchar i,j;for(j=0;j<a;j++){P0=P1=P2=P3=0xff;for(i=0;i<8;i++){P0=table3[i];P1=P2=P3=table2[i];delay(t);}}}void hwzjl(uint t,uchar a) //横往中间亮{uchar i,j;for (j=0;j<a;j++){P0=P1=P2=P3=0xff;for(i=0;i<8;i++){P0=P2=P1=table1[i];P3=table[i];delay(t);}}}void hwzjm(uint t,uchar a) //横往中间灭{uchar i,j;for (j=0;j<a;j++){P0=P1=P2=P3=0x00;for(i=0;i<8;i++){P0=P2=P1=table3[i];P3=table2[i];delay(t);}}}/*void swzjl(uint t,uchar a) //竖往中间亮{uchar i,j;for (j=0;j<a;j++){P0=P1=P2=P3=0xff;for(i=0;i<8;i++){P0=P2=P1=table[i];P3=table1[i];delay(t);}}}void swzjm(uint t,uchar a) //竖往中间灭{uchar i,j;for (j=0;j<a;j++){P0=P1=P2=P3=0x00;for(i=0;i<8;i++){P0=P2=P1=table2[i];P3=table3[i];delay(t);}}}*/void nzdl(uint t,uchar a) //逆时逐段亮{uchar i,j;for (j=0;j<a;j++){P0=P1=P2=P3=0xff;for(i=0;i<8;i++){P0=table1[i];delay(t);}P0=0xff;for(i=0;i<8;i++){P1=table[i];delay(t);}P1=0xff;for(i=0;i<8;i++){P3=table[i];delay(t);}P3=0xff;for(i=0;i<8;i++){P2=table[i];delay(t);}P2=0xff;}}void nzdgl(uint t,uchar a) //逆时逐段一个点亮{uchar i,j,k,l;for (j=0;j<a;j++){k=table1[0];P0=k;l=table[0];P1=P2=P3=l;delay(t);for(i=0;i<8;i++){k=_crol_(k,-1);P0=k;l=_crol_(l,1);P1=P2=P3=l;delay(t);}}}void jgs(uint t,uchar a) //间隔闪{uchar j;for (j=0;j<a;j++){P0=0x55;P1=P2=P3=0xaa;delay(t);P0=0xaa;P1=P2=P3=0x55;delay(t);}}void main(){uchar i;while(1){zg(100,1); //两边逐个亮lbzgm(100,1); //两边逐个灭jgs(300,10);djs(100,20); //对角闪////////////////////////////////////////////P1=P2=P3=0xff;for(i=0;i<3;i++){P0=0x00;delay(800);P0=0xff;delay(800);}P0=0x00;for(i=0;i<3;i++){P1=0x00;delay(800);P1=0xff;delay(800);}P1=0x00;for(i=0;i<3;i++){P3=0x00;delay(800);P3=0xff;delay(800);}P3=0x00;for(i=0;i<3;i++){P2=0x00;delay(800);P2=0xff;delay(800);}qs(500,3);/////////////////////////////////////////////for(i=0;i<6;i++){zgxh(50,1);nszgm(50,1);}djs(100,20); //对角闪for(i=0;i<3;i++){zg(100,1); //两边逐个亮lbzgm(100,1); //两边逐个灭}qs(200,10);djs(100,50);for(i=0;i<5;i++){sztl(200,1); //顺时逐个同步亮nztm(200,1);nztl(200,1);sztm(200,1); //顺时逐个同步灭}djs(300,10); //对角闪nzdgl(300,10); //逆时逐段一个点亮jgs(300,10); //间隔闪for(i=0;i<3;i++){zgxh(100,1);nszgm(100,1);}/*for(i=0;i<5;i++){zgxh1(100,1);sszgm(100,1);}*/nzdl(200,3); //逆时逐段亮jgs(50,100); //间隔闪/*/////////////////////////////////////////////////////P0=P1=P2=P3=0xff;for (i=0;i<8;i++){P0=table1[i];delay(200);}for (i=0;i<8;i++){P1=table[i];delay(200);}for(i=0;i<3;i++){P0=P1=0x00;delay(200);P0=P1=0xff;delay(200);}for (i=0;i<8;i++){P2=table1[i];delay(200);}for (i=0;i<8;i++){P3=table1[i];delay(200);}for(i=0;i<3;i++){P2=P3=0x00;delay(200);P2=P3=0xff;delay(200);}*///////////////////////////////////////////////////nzdgl(50,40); //逆时逐段一个点亮for(i=0;i<4;i++){zg(100,1);qs(100,10);lbzgm(100,1);}// djs(50,100); //对角闪for(i=0;i<3;i++){zgxh(100,1);nszgm(100,1);}djs(1000,10);for(i=0;i<10;i++){hwzjl(200,1); //横往中间亮hwzjm(200,1); //横往中间灭}djs(300,10); //对角闪/* for(i=0;i<10;i++){swzjl(200,1); //竖往中间亮swzjm(200,1); //竖往中间灭}*/for(i=0;i<5;i++){zgxh(100,1);nszgm(100,1);}djs(100,20); //对角闪zg(300,1);lbzgm(300,1);/*for(i=0;i<5;i++){zgxh1(100,1);sszgm(100,1);}*/for(i=0;i<5;i++){sztl(200,1); //顺时逐个同步亮nztm(200,1);nztl(200,1);sztm(200,1); //顺时逐个同步灭}djs(500,20); //对角闪djs(100,30); //对角闪djs(50,50); //对角闪// djs(10,100); //对角闪delay(1000);}}void delay(uint t){uint x,y;for (x=t;x>0;x--){for (y=120;y>0;y--);}}。

心形流水灯程序

心形流水灯程序

#include<reg52.h>#define uchar unsigned charuchar flag=200;///////////////////////////////////////////////////////////////////////uchar code Tab1[]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,0xFF};//暗中左移向下uchar code Tab2[]={0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF};//暗中右移向上uchar code Tab3[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00};//亮中左移向下uchar code Tab4[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00};//亮中右移向上uchar code Tab11[]={0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0xff};//暗中左移向下uchar code Tab22[]={0x7F,0x3F,0x1F,0x0F,0x07,0x03,0x01,0x00,0xff};////////////////////////////////////////////////////////////////////uchar code Tab33[]={0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF};uchar code Tab44[]={0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};uchar code Tab55[]={0x08,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xff};uchar code Tab5[]={0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xff};uchar code Tab6[]={0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xff};uchar code Tab7[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};uchar code Tab8[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};////////////////////////////////////////////////////////////////void shansuo();void xl();///////////////////////////////////////////////////////////////void delay(void){unsigned char m,n;for(m=0;m<flag;m++)for(n=0;n<250;n++);}///////////////////////////////////void hy1(void) //点亮状态逆时针旋转90度(一个一个灭){unsigned char i;for(i=0;i<8;i++){P0=Tab11[i];P1=Tab22[i];P2=Tab11[i];P3=Tab22[i];delay();}for(i=0;i<8;i++){P0=Tab44[i];P1=Tab55[i];P2=Tab44[i];P3=Tab55[i];delay();}///////////////////////////////////////////void hy2(void) //暗中逆时针转360。

32个灯心形流水灯程序

32个灯心形流水灯程序

#include<reg52.h>#include <intrins.h>#define uint unsigned int#define uchar unsigned char//延时void delay(uint k){uint i,j;for(i=k;i--;i>0)for(j=100;j--;j>0);}void main(){uchar temp0,temp1;uchar yi;uchar yi0,yi1;uint i,j,k,a,b;j=k=a=b=3;//全部亮P0=P1=P2=P3=0x00;delay(700);P0=P1=P2=P3=0xff;//每个io口独自亮for(i=2;i--;i>0){P1=P0=0x00;delay(500);P1=P0=0xff;P3=P2=0x00;delay(500);P3=P2=0xff;}//全部亮,闪三次for(i=2;i--;i>0){P0=P1=P2=P3=0x00;delay(100);P0=P1=P2=P3=0xff;delay(100);}//P1、P2亮,P3、P0暗for(i=3;i--;i>0){P1=0x00,P2=0x00; P3=0xff,P0=0xff;delay(500);P1=0xff,P2=0xff,P3=0x00,P0=0x00;delay(500);}//四个点的流水while(j>0){temp0=0xfe,temp1=0x7f;P1=P3=temp0,P2=P0=temp1;delay(100);for(i=7;i--;i>0){temp0=_crol_(temp0,1),temp1=_cror_(temp1,1);P1=P3=temp0,P2=P0=temp1;delay(100);}j--;}//全部亮,闪三次for(i=3;i--;i>0){P0=P1=P2=P3=0x00;delay(300);P0=P1=P2=P3=0xff;delay(300);}//四个IO口同样跟踪流水while(k>0){temp0=0xfe,temp1=0x7f;P1=P3=temp0,P2=P0=temp1;delay(60);for(i=7;i--;i>0){temp0=temp0<<1,temp1=temp1>>1;P1=P3=temp0,P2=P0=temp1;delay(60);}k--;}P0=P1=P3=P2=0xff;while(k<3){temp0=0x7f,temp1=0xfe;P1=P3=temp0,P2=P0=temp1;delay(60);for(i=7;i--;i>0){temp0=temp0>>1,temp1=temp1<<1;P1=P3=temp0,P2=P0=temp1;delay(60);}k++;}P3=P2=0xff;//两边单个从上向下流水yi=0xfe;P1=P0=yi;delay(50);for(i=7;i--;i>0){yi=_crol_(yi,1);P1=P0=yi;delay(50);}P1=P0=0xff;yi=0xfe;P3=P2=yi;delay(50);for(i=7;i--;i>0){yi=_crol_(yi,1);P3=P2=yi;delay(50);}P3=P2=0Xff;//两边单个返回流水for(i=7;i--;i>0){yi=_cror_(yi,1);P3=P2=yi;delay(50);}P3=P2=0xff;for(i=7;i--;i>0){yi=_cror_(yi,1);P0=P1=yi;delay(50);}//全部亮,闪三次P0=P1=P3=P2=0xff;for(i=3;i--;i>0){P0=P1=P2=P3=0x00;delay(100);P0=P1=P2=P3=0xff;delay(100);}//流水灯yi0=0xfe,yi1=0x7f;P3=P2=yi1,P1=P0=yi0;delay(100);for(i=7;i--;i>0){yi0=yi0<<1, yi1=yi1>>1;P1=P0=yi0,P3=P2=yi1;delay(100);}P1=P2=P3=P0=0xff;delay(200);yi0=0x7f,yi1=0xfe;P1=P0=yi0,P3=P2=yi1;for(i=7;i--;i>0){yi0=yi0>>1,yi1=yi1<<1;P1=P0=yi0,P3=P2=yi1;delay(100);}//大循环跟踪流水P1=P2=P3=P0=0xff;for(i=8;i--;i>0){P1=P1<<1;delay(50);}for(i=8;i--;i>0){P3=P3<<1;delay(50);}for(i=8;i--;i>0){P2=P2>>1;delay(50);}for(i=8;i--;i>0){P0=P0>>1;delay(50);}//逆向大循环跟踪流水P1=P2=P3=P0=0xff;for(i=8;i--;i>0){P0=P0<<1;delay(50);}for(i=8;i--;i>0){P2=P2<<1;delay(50);}for(i=8;i--;i>0){P3=P3>>1;delay(50);}for(i=8;i--;i>0){P1=P1>>1;delay(50);}//全部亮,闪三次P0=P1=P3=P2=0xff;for(i=4;i--;i>0){P0=P1=P2=P3=0x00;delay(100);P0=P1=P2=P3=0xff;delay(100);}//全部亮,只有一个暗的在流水temp0=0x01,temp1=0x00;P1=P0=temp0,P3=P2=temp1;delay(100);for(i=7;i--;i>0){temp0=_crol_(temp0,1);P1=P0=temp0;delay(100);}P1=P0=0x00;temp1=0x01;P3=P2=temp1;delay(100);for(i=7;i--;i>0){temp1=_crol_(temp1,1);P3=P2=temp1;delay(100);}//全部亮,逆向一个暗在流水temp0=0x00,temp1=0x80;P1=P0=temp0,P3=P2=temp1;delay(100);for(i=7;i--;i>0){temp1=_cror_(temp1,1);P3=P2=temp1;delay(100);}P3=P2=0x00;temp0=0x80;P1=P0=temp0;delay(100);for(i=7;i--;i>0){temp0=_cror_(temp0,1);P1=P0=temp0;}//花样temp0=0xaa,temp1=0x55;P1=P3=temp0,P2=P0=temp1;delay(500);for(;a--;a>0){for(i=7;i--;i>0){temp0=_crol_(temp0,1),temp1=_cror_(temp1,1);P1=P3=temp0,P2=P0=temp1;delay(500);}}for(;b--;b>0){temp0=0xee,temp1=0x77;P1=P3=temp0,P2=P0=temp1;delay(300);for(i=7;i--;i>0){temp0=_crol_(temp0,1),temp1=_cror_(temp1,1);P1=P3=temp0,P2=P0=temp1;delay(300);}}//环形逐个亮P1=P2=P3=P0=0xff;for(i=8;i--;i>0){P0=P0<<1;delay(50);}for(i=8;i--;i>0){P2=P2<<1;delay(50);}for(i=8;i--;i>0){P3=P3>>1;}for(i=8;i--;i>0){P1=P1>>1;delay(50);}//逐个熄灭for(i=7;i--;i>0){P0=~P0<<1;P0=~P0;delay(50);}P0=0xff;for(i=7;i--;i>0){P2=~P2<<1;P2=~P2;delay(50);}P2=0xff;for(i=7;i--;i>0){P3=~P3>>1;P3=~P3;delay(50);}P3=0xff;for(i=7;i--;i>0){P1=~P1>>1;P1=~P1;delay(50);}P1=0xff;}。

心形流水灯叠加代码一个到8个叠加。

心形流水灯叠加代码一个到8个叠加。

心形流水灯叠加代码一个到8个叠加。

#include#define uint unsigned int#define uchar unsigned char#includeuchar c1[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//高位往低位移动加uchar c2[7]={0x7e,0xbe,0xde,0xee,0xf6,0xfa,0xfc};uchar c3[6]={0x7c,0xbc,0xdc,0xec,0xf4,0xf8};uchar c4[5]={0x78,0xb8,0xd8,0xe8,0xf0};uchar c5[4]={0x70,0xb0,0xd0,0xe0};uchar c6[3]={0x60,0xa0,0xc0};uchar c7[2]={0x40,0x80};uchar b3[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};// 低位向高位移动0--7 // uchar b4[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};/// 高位向低位移动7--0 // uchar a1[7]={0x7e,0x7d,0x7b,0x77,0x6f,0x5f,0x3f}; //一个点到两个点uchar a2[6]={0x3e,0x3d,0x3b,0x37,0x2f,0x1f}; // 两个到三个uchar a3[5]={0x1e,0x1d,0x1b,0x17,0x0f}; // 三个到四个uchar a4[4]={0x0e,0x0d,0x0b,0x07};//4个到5个uchar a5[3]={0x06,0x05,0x03};//5个到6个uchar a6[2]={0x02,0x01};//6到7//////////////////////////////////////////void delay(int t){ int i;while(t--){ for( i=114; i>0;i--);}}//////////////////////////// void m() ///跑3段{ int i,s;s=30;for(i=0;i<8;i++){ P3=b3[i];delay(s);}P3=0xff;for(i=0;i<8;i++){P2=b3[i];delay(s);}P2=0xff;for(i=0;i<8;i++){P0=b4[i];delay(s);}P0=0xff; delay(s);}/////////////////////////// void m1() //跑两段{int i,s;s=50;for(i=0;i<8;i++){ P3=b3[i];delay(s);}P3=0xff;for(i=0;i<8;i++){P2=b3[i];delay(s);}P2=0xff; delay(s);}void m2() //跑一段{int i,s;s=50;for(i=0;i<8;i++){ P3=b3[i];delay(s);}P3=0xff;delay(s);}////////////////////////////////////////////////////延时函数void main (){ int i,s; s=50;// P1=P0=P2=P3=0XFF;for(i=0;i<8;i++){ P3=b3[i];delay(s);}P3=0xff;for(i=0;i<8;i++)P2=b3[i];delay(s);}P2=0xff;for(i=0;i<8;i++){P0=b4[i];delay(s);}P0=0xff;for(i=0;i<8;i++){P1=b3[i];delay(s);}//while(1);/////////一个点完成m();for(i=0;i<7;i++){P1=a1[i];delay(s);}////第一段第二个点完成for(i=0;i<8;i++){ P3=b3[i];delay(s);}P3=0xff;for(i=0;i<8;i++)P2=b3[i];delay(s);}P2=0xff;for(i=0;i<8;i++)P0=b4[i];delay(s);}P0=0xff;for(i=0;i<6;i++){P1=a2[i];delay(s);} //第一段第三点完成///////////////////////////////// m();for(i=0;i<5;i++){P1=a3[i];delay(s);} ////////第一段第4点亮m();for(i=0;i<4;i++){P1=a4[i];delay(s);}//////////////第一段第五个灯亮m();for(i=0;i<3;i++){P1=a5[i];delay(s);//////////////第一段第6个亮m();for(i=0;i<2;i++){P1=a6[i];delay(s);} /////第一段第7个亮m();P1=0x00;delay(s);/////第一段第8个亮//////////////////////////////第一段全部亮转下一段for(i=0;i<8;i++){P0=c1[i];delay(s);} ///////////////第2段第一点亮m1();for(i=0;i<7;i++){P0=c2[i];delay(s);}m1();for(i=0;i<6;i++){P0=c3[i];delay(s);}m1();for(i=0;i<5;i++){P0=c4[i];delay(s);}m1();for(i=0;i<4;i++){P0=c5[i];delay(s);}m1();for(i=0;i<3;i++){P0=c6[i];delay(s);}m1();for(i=0;i<2;i++){P0=c7[i];delay(s);}m1();P0=0x00; delay(s);////////////////////////////////第二段全亮/////////////////////////////第2段全亮m2(); for(i=0;i<8;i++){P2=b3[i];delay(s);}m2();for(i=0;i<7;i++){P2=a1[i];delay(s);}m2();for(i=0;i<6;i++){P2=a2[i];delay(s);}m2();for(i=0;i<5;i++){P2=a3[i];delay(s);}m2();for(i=0;i<4;i++){P2=a4[i];delay(s);}m2();for(i=0;i<3;i++){P2=a5[i];delay(s);}m2();for(i=0;i<2;i++){P2=a6[i];delay(s);}m2();P2=0x00; delay(s);//////////////////////第3段全亮for(i=0;i<8;i++){P3=b3[i];delay(s); }for(i=0;i<7;i++) {P3=a1[i];delay(s); } for(i=0;i<6;i++) { P3=a2[i];delay(s); } for(i=0;i<5;i++) { P3=a3[i];delay(s); } for(i=0;i<4;i++) { P3=a4[i];delay(s); } for(i=0;i<3;i++) { P3=a5[i];delay(s); } for(i=0;i<2;i++) { P3=a6[i];delay(s); } P3=0x00; delay(s); }。

爱心流水灯程序

爱心流水灯程序

#define uint unsigned int #define uchar unsigned charsbit p0_1=P0^0;sbit p0_2=P0^1;sbit p0_3=P0^2;sbit p0_4=P0^3;sbit p0_5=P0^4;sbit p0_6=P0^5;sbit p0_7=P0^6;sbit p0_8=P0^7;sbit p1_1=P1^0;sbit p1_2=P1^1;sbit p1_3=P1^2;sbit p1_4=P1^3;sbit p1_5=P1^4;sbit p1_6=P1^5;sbit p1_7=P1^6;sbit p1_8=P1^7;sbit p2_1=P2^0;sbit p2_2=P2^1;sbit p2_3=P2^2;sbit p2_4=P2^3;sbit p2_5=P2^4;sbit p2_6=P2^5;sbit p2_7=P2^6;sbit p2_8=P2^7;sbit p3_1=P3^0;sbit p3_2=P3^1;sbit p3_3=P3^2;sbit p3_4=P3^3;sbit p3_5=P3^4;sbit p3_6=P3^5;sbit p3_7=P3^6;sbit p3_8=P3^7;void delay(uint);uchar temp0;uchar temp1;uchar temp3;uint k,s;void delay(uint j){uint i;for(j;j>0;j--)for(i=120;i>0;i--);}void main(){while(1){for(k=0;k<4;k++){P0=0x00;P1=0x00;P2=0x00;P3=0x00;delay(500);P0=0xff;P1=0xff;P2=0xff;P3=0xff;delay(500); }for(k=0;k<7;k++) {temp0=0x01;P0=temp0;delay(100);for(k=0;k<8;k++){s=temp0<<1;P0=s;delay(50);}P0=0xff;temp2=0x01;P2=temp0;delay(100);for(k=0;k<8;k++) {s=temp2<<1;P2=s;delay(50);}P2=0xff;temp3=0x01;P3=temp0;delay(100);for(k=0;k<8;k++) {s=temp3<<1;P3=s;delay(50);}P3=0xff;temp1=0x01;P1=temp0;delay(100);for(k=0;k<8;k++) {s=temp1<<1;P1=s;delay(50);}delay(500);temp1=0x01;P1=temp1;delay(100);for(k=0;k<7;k++) {s=temp1>>1;P1=s;delay(50);}P1=0xff;temp3=0x01;P3=temp3;delay(50);for(k=0;k<8;k++){s=temp3<<1;P3=s;delay(50);}P3=0xff;temp2=0x01;P2=temp2;delay(50);for(k=0;k<8;k++){s=temp2<<1;P2=s;delay(50);}P2=0xff;temp0=0x01;P0=temp0;delay(50);for(k=0;k<8;k++){s=temp0>>1;P0=s;delay(50);}P0=0xff;}delay(1000);for(k=0;k<2;k++){p1_1=0;delay(50);p1_2=0;delay(50);p1_3=0;delay(50);p1_4=0;delay(50);p1_5=0; delay(50); p1_6=0; delay(50); p1_7=0; delay(50); p1_8=0; delay(50);p3_1=0; delay(50); p3_2=0; delay(50); p3_3=0; delay(50); p3_4=0; delay(50); p3_5=0; delay(50); p3_6=0; delay(50); p3_7=0; delay(50); p3_8=0; delay(50);p2_1=0; delay(50); p2_2=0; delay(50); p2_3=0; delay(50); p2_4=0; delay(50); p2_5=0; delay(50); p2_6=0; delay(50); p2_7=0; delay(50); p2_8=0; delay(50);p0_8=0;delay(50);p0_7=0;delay(50);p0_6=0;delay(50);p0_5=0;delay(50);p0_4=0;delay(50);p0_3=0;delay(50);p0_2=0;delay(50);p0_1=0;delay(50);/*......*/p1_1=1;delay(50);p1_2=1;delay(50);p1_3=1;delay(50);p1_4=1;delay(50);p1_5=1;delay(50);p1_6=1;delay(50);p1_7=1;delay(50);p1_8=1;delay(50);p3_1=1;delay(50);p3_2=1;delay(50);p3_3=1; delay(50); p3_4=1; delay(50); p3_5=1; delay(50); p3_6=1; delay(50); p3_7=1; delay(50); p3_8=1;delay(50);p2_1=1; delay(50); p2_2=1; delay(50); p2_3=1; delay(50); p2_4=1; delay(50); p2_5=1; delay(50); p2_6=1; delay(50); p2_7=1; delay(50); p2_8=1;delay(50);p0_8=1; delay(50); p0_7=1; delay(50); p0_6=1; delay(50); p0_5=1; delay(50); p0_4=1; delay(50); p0_3=1;delay(50); p0_2=1; delay(50); p0_1=1; delay(50);/*......*/p0_1=0; delay(50); p0_2=0; delay(50); p0_3=0; delay(50); p0_4=0; delay(50); p0_5=0; delay(50); p0_6=0; delay(50); p0_7=0; delay(50); p0_8=0; delay(50);p2_8=0; delay(50); p2_7=0; delay(50); p2_6=0; delay(50); p2_5=0; delay(50); p2_4=0; delay(50); p2_3=0; delay(50); p2_2=0; delay(50); p2_1=0; delay(50);delay(50); p3_7=0; delay(50); p3_6=0; delay(50); p3_5=0; delay(50); p3_4=0; delay(50); p3_3=0; delay(50); p3_2=0; delay(50); p3_1=0; delay(50);p1_8=0; delay(50); p1_7=0; delay(50); p1_6=0; delay(50); p1_5=0; delay(50); p1_4=0; delay(50); p1_3=0; delay(50); p1_2=0; delay(50); p1_1=0; delay(50);/*......*/p0_1=1; delay(50); p0_2=1; delay(50); p0_3=1; delay(50);delay(50); p0_5=1; delay(50); p0_6=1; delay(50); p0_7=1; delay(50); p0_8=1; delay(50);p2_8=1; delay(50); p2_7=1; delay(50); p2_6=1; delay(50); p2_5=1; delay(50); p2_4=1; delay(50); p2_3=1; delay(50); p2_2=1; delay(50); p2_1=1;delay(50);p3_8=1; delay(50); p3_7=1; delay(50); p3_6=1; delay(50); p3_5=1; delay(50); p3_4=1; delay(50); p3_3=1; delay(50); p3_2=1; delay(50);delay(50);p1_8=1;delay(50);p1_7=1;delay(50);p1_6=1;delay(50);p1_5=1;delay(50);p1_4=1;delay(50);p1_3=1;delay(50);p1_2=1;delay(1);p1_1=1;delay(50);/*..........*/for(k=0;k<3;k++){p1_1=0;delay(50);p1_2=0;p0_1=0;delay(50);p1_3=0;p0_2=0;delay(50);p1_4=0;p0_3=0;delay(40);p1_5=0;p0_4=0;delay(50);p1_6=0;p0_5=0;delay(50);p1_7=0;p0_6=0;delay(50);p0_7=0;delay(50);p3_1=0;p0_8=0;delay(50);p3_2=0;p2_8=0;delay(50);p3_3=0;p2_7=0;delay(50);p3_4=0;p2_6=0;delay(50);p3_5=0;p2_5=0;delay(50);p3_6=0;p2_4=0;delay(50);p3_7=0;p2_3=0;delay(50);p3_8=0;p2_2=0;delay(50);p2_1=0;delay(50);/*......*/p2_1=1;delay(50); p3_8=1;p2_2=1;delay(35);p3_7=1;p2_3=1;delay(50); p3_6=1;p2_4=1;delay(50); p3_5=1;p2_5=1;delay(50); p3_4=1;p2_6=1;delay(35); p3_3=1;p2_7=1;delay(50); p3_2=1;p2_8=1;delay(50); p3_1=1;p0_8=1;delay(35); p1_8=1;p0_7=1;delay(50); p1_7=1;p0_6=1;delay(50); p1_6=1;p0_5=1;delay(50); p1_5=1;p0_4=1;delay(50); p1_4=1;p0_3=1;delay(50); p1_3=1;p0_2=1;delay(50); p1_2=1;p0_1=1;delay(50); p1_1=1;delay(50);}}/***********/delay(400);P0=0x00;P1=0x00;P2=0x00;P3=0x00;delay(400);for(k=0;k<4;k++){P0=0x00;P1=0x00;P2=0x00;P3=0x00;delay(200);P0=0xff;P1=0xff;P2=0xff;P3=0xff;delay(200); }for(k=0;k<72;k++) {P0=0x55;P1=0x55;P2=0x55;P3=0x55;delay(100);P0=0xaa;P1=0xaa;P2=0xaa;P3=0xaa;delay(100); }P1=0xff;P2=0xff;P3=0xff;delay(500);/*.......*/for(k=0;k<4;k++){P0=0xff;P1=0xff;P2=0xff;P3=0xff;delay(200);P0=0xf0;delay(20);P0=0x00;delay(20);P2=0xf0;delay(20);P2=0x00;delay(300);P0=0xff;P2=0xff; delay(300);P3=0x00f;delay(20);P3=0x00;delay(20);P1=0x00f;delay(20);P1=0x00;delay(300);}for(k=0;k<7;k++){temp1=0x01;delay(100);for(k=0;k<7;k++) {s=temp1>>1;P1=s;delay(50);}P1=0xff;temp3=0x01;P3=temp3;delay(100);for(k=0;k<8;k++) {s=temp3<<1;P3=s;delay(50);}P3=0xff;temp2=0x01;P2=temp2;delay(100);for(k=0;k<8;k++) {s=temp2<<1;P2=s;delay(50);}P2=0xff;temp0=0x01;P0=temp0;delay(100);for(k=0;k<8;k++) {s=temp0>>1;P0=s;delay(50);}P0=0xff;delay(500);temp0=0x01;P0=temp0;for(k=0;k<8;k++) {s=temp0<<1;P0=s;delay(50);}P0=0xff;temp2=0x01;P2=temp0;delay(100);for(k=0;k<8;k++) {s=temp2<<1;P2=s;delay(50);}P2=0xff;temp3=0x01;P3=temp0;delay(100);for(k=0;k<8;k++) {s=temp3<<1;P3=s;delay(50);}P3=0xff;temp1=0x01;P1=temp0;delay(100);for(k=0;k<8;k++) {s=temp1<<1;P1=s;delay(50);}}for(k=0;k<3;k++) {P0=0x00;P1=0x00;P2=0x00;P3=0x00;delay(100);P0=0xff;P1=0xff;P2=0xff;P3=0xff;delay(100);}delay(400);temp0=0x0f; temp2=0xf0; temp3=0x0f; temp1=0x0f;for(k;k<240;k++){P0=temp0;P2=temp2;P3=temp3;P1=temp1;temp0=_crol_(temp0,1);delay(10);temp2=_cror_(temp2,1);delay(10);temp3=_cror_(temp3,1);delay(10);temp1=_cror_(temp1,1);delay(10);}delay(500);P0=0xff;P1=0xff;P2=0xff;P3=0xff;delay(1000);temp0=0x7f; temp2=0xfe; temp3=0xfe; temp1=0xfe;for(k;k<240;k++){P0=temp0;P2=temp2;P3=temp3;P1=temp1;temp0=_cror_(temp0,1);delay(70);temp2=_crol_(temp2,1);delay(700);temp3=_crol_(temp3,1);delay(70);temp1=_crol_(temp1,1);delay(70);}delay(400);P1=0xf0;delay(500);P1=0xff;P1=0x00;delay(500);P1=0xff;P3=0xf0;delay(500);P3=0xff;P3=0x0f;delay(500);P3=0xff;P2=0xf0;delay(500);P2=0xff;P2=0x0f;delay(500);P2=0xff;P0=0x0f;delay(500);P0=0xff;P0=0xf0;delay(500);P0=0xff;delay(500);for(k=0;k<49;k++){P1=0xf0;delay(20);P1=0xff;P1=0x00;delay(20);P1=0xff;P3=0xf0;delay(20);P3=0xff;P3=0x0f;delay(20);P3=0xff;P2=0xf0;delay(20);P2=0xff;P2=0x0f;delay(20);P2=0xff;P0=0x0f;delay(20);P0=0xff;P0=0xf0;delay(20);P0=0xff;}delay(1000);for(k=0;k<2;k++){P0=0x00;P1=0x00;P2=0x00;P3=0x00;delay(200);P0=0xff;P1=0xff;P2=0xff;P3=0xff;delay(400); }delay(5000);}}。

心形流水灯制作教程

心形流水灯制作教程

亲,感谢你的支持并购买“新生科技电子卖场”的宝贝,网店网址:心形流水灯制作教程1、制作前先用笔对焊孔进行描绘。

这时候亲会注意到最顶上的焊孔有着些数字,只要数着这些数字并在对应的格数画上点就可以了。

具体画点参照图片。

2、画完焊孔以后进行对纸板的粘贴。

撕开胶纸后粘贴在板子上面。

粘贴后的板子3、翻到板子后面,对焊孔一一进行戳破。

可以用LED灯的灯脚剪尖进行操作。

戳好的板子正面如下图4、将LED安照戳好的洞口进行排版,记住LED排放的位置都是在外围的为正极,因为最后正极是需要全部焊接在一起的。

切记了。

刚刚排好的灯会七倒八歪的,所以要进行下面一个步骤。

6、把排版好了以后的板子翻转,然后分别先给每个LED的正极点上焊点。

负极先不需要点。

点完焊点后,一只手在后面按着LED灯,一只手用焊铁融对应的焊点,这样子LED就会被按得平平的,不会七倒八歪的了。

等全部整平整了以后,剪去长出来的引脚。

并焊上负极的点,如下图:7、给单片机上焊点(注意数点即可),如图,并给板子走上正极的焊线。

走线图如下:8、给单片机焊上晶振以及电容。

如图,晶振两个脚分别串联上电容一端再分别一个接单片机的第18个脚,一个接单片机的第19个脚。

电容剩下的连接单片机负极。

(单片机脚的定位参照配件附带的纸片。

)正面:背面:9、贴上贴片电阻,单片机上一共要焊32个贴片电阻,每8个一组。

焊贴片电阻时,先将贴片电阻八个八个弄出来,一个个放在板子上面贴着单片机脚的焊点上,用焊铁融化焊点时,贴片会被吸入。

至于北面走线的,请按照我给的图片进行焊接,不然会出现空间不够走焊线的情况。

其中的P3.8脚采用跳线焊接。

如果你全部做好了,那么恭喜你,成功的用自己的双手做出了一个精美的心形流水灯。

亲,在制作过程中有任何不懂的地方都可以随时向我说出来的。

再次欢迎你再次光临“新生科技卖场”网店网址:本店还有LED电子沙漏提供购买。

51芯片超炫爱心流水程序灯代码

51芯片超炫爱心流水程序灯代码

#include<reg52.h>sbit P00=P0^0;sbit P01=P0^1;sbit P02=P0^2;sbit P03=P0^3;sbit P04=P0^4;sbit P05=P0^5;sbit P06=P0^6;sbit P07=P0^7;sbit P10=P1^0;sbit P11=P1^1;sbit P12=P1^2;sbit P13=P1^3;sbit P14=P1^4;sbit P15=P1^5;sbit P16=P1^6;sbit P17=P1^7;sbit P20=P2^0;sbit P21=P2^1;sbit P22=P2^2;sbit P23=P2^3;sbit P24=P2^4;sbit P25=P2^5;sbit P26=P2^6;sbit P27=P2^7;sbit P30=P3^0;sbit P31=P3^1;sbit P32=P3^2;sbit P33=P3^3;sbit P34=P3^4;sbit P35=P3^5;sbit P36=P3^6;sbit P37=P3^7;unsigned int x,y;void rzmzy(); //红色走马左移声明void rzmyy(); //红色走马右移声明void rzmnwyd(); //红色走马内外移动声明void rtbyd(); //红色跳变移动声明void rjl(); //红色渐亮声明void rja(); //红色渐暗声明void rP0ja();//P0渐暗void zkb(unsigned char d);void delayms(int z)//延时声明,修改s的数值,就可以改变时间{int i,j;for(i=z;i>0;i--)for(j=110;j>0;j--);}void Onall() //开启所有灯{P0=0x00;P1=0x00;P2=0x00;P3=0x00;}void Offall()//关闭所有灯{P0=0xff;P1=0xff;P2=0xff;P3=0xff;}//void fxls()//逆时针逐个等时流水灯//{// P0=0xfe;delayms(50);// P0=0xfd;delayms(50);// P0=0xfb;delayms(50);// P0=0xf7;delayms(50);// P0=0xef;delayms(50);// P0=0xdf;delayms(50);// P0=0xbf;delayms(50);// P0=0x7f;delayms(50);// P0=0xff;//// P2=0x7f;delayms(50);// P2=0xbf;delayms(50);// P2=0xdf;delayms(50);// P2=0xef;delayms(50);// P2=0xf7;delayms(50);// P2=0xfb;delayms(50);// P2=0xfd;delayms(50);// P2=0xfe;delayms(50);// P2=0xff;//// P3=0x7f;delayms(50);// P3=0xbf;delayms(50);// P3=0xdf;delayms(50);// P3=0xef;delayms(50);// P3=0xf7;delayms(50);// P3=0xfb;delayms(50);// P3=0xfe;delayms(50);// P3=0xff;//// P1=0x7f;delayms(50);// P1=0xbf;delayms(50);// P1=0xdf;delayms(50);// P1=0xef;delayms(50);// P1=0xf7;delayms(50);// P1=0xfb;delayms(50);// P1=0xfd;delayms(50);// P1=0xfe;delayms(50);// P1=0xff;//}//void ls()//顺时针逐个等时流水灯//{// Offall();// P1=0xfe;delayms(50);// P1=0xfd;delayms(50);// P1=0xfb;delayms(50);// P1=0xf7;delayms(50);// P1=0xef;delayms(50);// P1=0xdf;delayms(50);// P1=0xbf;delayms(50);// P1=0x7f;delayms(50);// P1=0xff;//// P3=0xfe;delayms(50);// P3=0xfd;delayms(50);// P3=0xfb;delayms(50);// P3=0xf7;delayms(50);// P3=0xef;delayms(50);// P3=0xdf;delayms(50);// P3=0xbf;delayms(50);// P3=0x7f;delayms(50);// P3=0xff;;//// P2=0xfe;delayms(50);// P2=0xfd;delayms(50);// P2=0xfb;delayms(50);// P2=0xf7;delayms(50);// P2=0xef;delayms(50);// P2=0xdf;delayms(50);// P2=0xbf;delayms(50);// P2=0xff;;//// P0=0x7f;delayms(50);// P0=0xbf;delayms(50);// P0=0xdf;delayms(50);// P0=0xef;delayms(50);// P0=0xf7;delayms(50);// P0=0xfb;delayms(50);// P0=0xfd;delayms(50);// P0=0xfe;delayms(50);// P0=0xff;//}void bsb()//双边同时流水由上至下{Offall();delayms(50);P0=0xfe;delayms(50);P0=0xfd;P1=0xfe;delayms(50);P0=0xfb;P1=0xfd;delayms(50);P0=0xf7;P1=0xfb;delayms(50);P0=0xef;P1=0xf7;delayms(50);P0=0xdf;P1=0xef;delayms(50);P0=0xbf;P1=0xdf;delayms(50);P0=0x7f;P1=0xbf;delayms(50);P0=0xff;P2=0x7f;P1=0x7f;delayms(50);P1=0xff;P2=0xbf;P3=0xfe;delayms(50);P2=0xdf;P3=0xfd;delayms(50);P2=0xef;P3=0xfb;delayms(50);P2=0xf7;P3=0xf7;delayms(50);P2=0xfb;P3=0xef;delayms(50);P2=0xfd;P3=0xdf;delayms(50);P2=0xfe;P3=0xbf;delayms(50);P2=0xff;P3=0x7f;delayms(50);P3=0xff;}//void fbsb() //半双边流水由下至上//{// Offall();// P3=0x7f;delayms(80);// P2=0xfe;P3=0xbf;delayms(80);// P2=0xfd;P3=0xdf;delayms(80);// P2=0xfb;P3=0xef;delayms(80);// P2=0xf7;P3=0xf7;delayms(80);// P2=0xef;P3=0xfb;delayms(80);// P2=0xdf;P3=0xfd;delayms(80);// P2=0xbf;P3=0xfe;delayms(80);Offall(); // P2=0x7f;P1=0x7f;delayms(80);Offall(); //// P0=0x7f;P1=0xbf;delayms(80);// P0=0xbf;P1=0xdf;delayms(80);// P0=0xdf;P1=0xef;delayms(80);// P0=0xef;P1=0xf7;delayms(80);// P0=0xf7;P1=0xfb;delayms(80);// P0=0xfb;P1=0xfd;delayms(80);// P0=0xfd;P1=0xfe;delayms(80);// P0=0xfe;P1=0xff;delayms(80);//}void ss(y)//闪烁(y为闪烁间隔时间){Onall();delayms(y);Offall();delayms(y);}//void fxsz() //反向生长//{// Offall();// P0=0xfe;delayms(50);// P0=0xfc;delayms(50);// P0=0xf8;delayms(50);// P0=0xf0;delayms(50);// P0=0xe0;delayms(50);// P0=0xc0;delayms(50);// P0=0x80;delayms(50);// P0=0x00;delayms(50);//// P2=0x7f;delayms(50);// P2=0x3f;delayms(50);// P2=0x1f;delayms(50);// P2=0x0f;delayms(50);// P2=0x07;delayms(50);// P2=0x03;delayms(50);// P2=0x01;delayms(50);// P2=0x00;delayms(50);//// P3=0x7f;delayms(50);// P3=0x3f;delayms(50);// P3=0x1f;delayms(50);// P3=0x0f;delayms(50);// P3=0x07;delayms(50); // P3=0x03;delayms(50); // P3=0x01;delayms(50); // P3=0x00;delayms(50); //// P1=0x7f;delayms(50);// P1=0x3f;delayms(50);// P1=0x1f;delayms(50);// P1=0x0f;delayms(50);// P1=0x07;delayms(50); // P1=0x03;delayms(50); // P1=0x01;delayms(50); // P1=0x00;delayms(50); //// Offall();delayms(100);// Onall();delayms(100);// Offall();delayms(100);// Onall();delayms(500);// Offall();delayms(50);//}void zxsz() //正向生长{Offall();P0=0xfe;delayms(50);P1=0xfe;delayms(50);P1=0xfc;delayms(50);P1=0xf8;delayms(50);P1=0xf0;delayms(50);P1=0xe0;delayms(50);P1=0xc0;delayms(50);P1=0x80;delayms(50);P1=0x00;delayms(50);P3=0xfe;delayms(50);P3=0xfc;delayms(50);P3=0xf8;delayms(50);P3=0xf0;delayms(50);P3=0xe0;delayms(50);P3=0xc0;delayms(50);P3=0x80;delayms(50);P3=0x00;delayms(50);P2=0xfe;delayms(50);P2=0xfc;delayms(50);P2=0xf8;delayms(50);P2=0xf0;delayms(50);P2=0xe0;delayms(50);P2=0xc0;delayms(50);P2=0x80;delayms(50);P2=0x00;delayms(50);P0=0x7e;delayms(50);P0=0x3e;delayms(50);P0=0x1e;delayms(50);P0=0x0e;delayms(50);P0=0x06;delayms(50);P0=0x02;delayms(50);P0=0x00;delayms(50);Offall();delayms(100);Onall();delayms(100);Offall();delayms(100);Onall();delayms(500);Offall();delayms(100);}//void fxsw() //反向死亡//{// Onall();// P0=0x01;delayms(50); // P0=0x03;delayms(50); // P0=0x07;delayms(50); // P0=0x0f;delayms(50);// P0=0x1f;delayms(50);// P0=0x3f;delayms(50);// P0=0x7f;delayms(50);// P0=0xff;delayms(50);//// P2=0x80;delayms(50); // P2=0xc0;delayms(50); // P2=0xe0;delayms(50); // P2=0xf0;delayms(50);// P2=0xf8;delayms(50);// P2=0xfc;delayms(50);// P2=0xff;delayms(50);//// P3=0x80;delayms(50);// P3=0xc0;delayms(50);// P3=0xe0;delayms(50);// P3=0xf0;delayms(50);// P3=0xf8;delayms(50);// P3=0xfc;delayms(50);// P3=0xfe;delayms(50);// P3=0xff;delayms(50);//// P1=0x80;delayms(50);// P1=0xc0;delayms(50);// P1=0xe0;delayms(50);// P1=0xf0;delayms(50);// P1=0xf8;delayms(50);// P1=0xfc;delayms(50);// P1=0xfe;delayms(50);// P1=0xff;delayms(50);//}void c(x) //间隔闪烁x为闪烁间隔时间{Offall();P0=0xaa;P2=0x55;P3=0x55;P1=0x55;delayms(x);P0=0x55;P2=0xaa;P3=0xaa;P1=0xaa;delayms(x);}/*----------------------------------------------------------*/void cx() //出现一点点{Offall();delayms(500);P0=0xff;P2=0xff;P1=0xbf;P3=0xff;delayms(500);P0=0xdf;P2=0xbf;P1=0xbf;P3=0xff;delayms(500);P0=0xdb;P2=0xbd;P1=0xbf;P3=0xfb;delayms(500);P0=0x59;P2=0xa5;P1=0x5d;P3=0x9a;delayms(500);P0=0x11;P2=0x20;P1=0x24;P3=0x10;delayms(500);P0=0x00;P2=0x00;P1=0x00;P3=0x00;delayms(500); }//void df() //单飞//{// P0=0xfe;delayms(50);// P0=0xfc;delayms(50);// P0=0xf0;delayms(50);// P0=0xe0;delayms(50);// P0=0xc0;delayms(50);// P0=0x80;delayms(50);// P0=0x00;delayms(50);//先引出单飞//// P0=0x01;delayms(50);// P0=0x03;delayms(50);// P0=0x07;delayms(50);// P0=0x0f;delayms(50);// P0=0x1f;delayms(50);// P0=0x3f;delayms(50);// P0=0x7f;delayms(50);// P0=0xff;delayms(50);//// P2=0x7f;delayms(50);// P2=0x3f;delayms(50);// P2=0x1f;delayms(50);// P2=0x0f;delayms(50);// P2=0xf7;delayms(50);// P2=0xf3;delayms(50);// P2=0xf1;delayms(50);// P2=0xf0;delayms(50);//// P3=0x7f;delayms(50);// P2=0x80;delayms(50);// P2=0xc0;delayms(50);// P2=0xe0;delayms(50);// P2=0xf0;delayms(50);// P2=0xf8;delayms(50);// P2=0xfc;delayms(50);// P2=0xfe;delayms(50);// P2=0xff;delayms(50);//// P3=0x7f;delayms(50);// P3=0x3f;delayms(50);// P3=0x1f;delayms(50);// P3=0x0f;delayms(50);// P3=0x07;delayms(50);// P3=0x03;delayms(50);// P3=0x01;delayms(50);// P3=0x00;delayms(50);//// P3=0xc0;delayms(50);// P3=0xe0;delayms(50);// P3=0xf0;delayms(50);// P3=0xf8;delayms(50);// P3=0xfc;delayms(50);// P3=0xfe;delayms(50);// P3=0xff;delayms(50);//// P1=0x7f;delayms(50);// P1=0x3f;delayms(50);// P1=0x1f;delayms(50);// P1=0x0f;delayms(50);// P1=0x07;delayms(50);// P1=0x03;delayms(50);// P1=0x01;delayms(50);// P1=0x00;delayms(50);//// P0=0x01;delayms(50);// P1=0x80;delayms(50);// P1=0xc0;delayms(50);// P1=0xe0;delayms(50);// P1=0xf0;delayms(50);// P1=0xf8;delayms(50);// P1=0xfc;delayms(50);// P1=0xfe;delayms(50);// P1=0xff;delayms(50);////}/*----------------------------------------------------------*/ void cdP00() //沉淀语句{P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfd;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);P2=0xff;P0=0xff;P0=0x7f;delayms(30);P0=0xbf;delayms(30);P0=0xef;delayms(30);P0=0xf7;delayms(30);P0=0xfb;delayms(30);P0=0xfd;delayms(30);P0=0xfe;delayms(30);}//P00void cdP01(){P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfd;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);P2=0xff;P0=0x7e;delayms(30);P0=0xbe;delayms(30);P0=0xde;delayms(30);P0=0xee;delayms(30);P0=0xf6;delayms(30);P0=0xfa;delayms(30);P0=0xfc;delayms(30);}//P01void cdP02(){P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfd;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);P2=0xff;P0=0x7c;delayms(30);P0=0xbc;delayms(30);P0=0xdc;delayms(30);P0=0xf4;delayms(30);P0=0xf8;delayms(30);}//P02void cdP03(){P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfd;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);P2=0xff;P0=0x78;delayms(30);P0=0xb8;delayms(30);P0=0xd8;delayms(30);P0=0xe8;delayms(30);P0=0xf0;delayms(30);}//P03void cdP04(){P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfd;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);P2=0xff;P0=0x70;delayms(30);P0=0xb0;delayms(30);P0=0xd0;delayms(30);P0=0xe0;delayms(30);}//P04void cdP05(){P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);P2=0xff;P0=0x60;delayms(30);P0=0xa0;delayms(30);P0=0xc0;delayms(30);}//P05void cdP06(){P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfd;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);P2=0xff;P0=0x40;delayms(30);P0=0x80;delayms(30);}//P06void cdP07(){P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfd;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);P2=0xff;P0=0x00;delayms(30);}//P07void cdP27(){P3=0x7f;delayms(30);P3=0xff;P2=0xfe;delayms(30);P2=0xfd;delayms(30);P2=0xfb;delayms(30);P2=0xf7;delayms(30);P2=0xef;delayms(30);P2=0xdf;delayms(30);P2=0xbf;delayms(30);P2=0x7f;delayms(30);}//P27void cdP26(){P3=0x7e;delayms(30);//P3=0xff;P2=0x7e;delayms(30);P2=0x7d;delayms(30);P2=0x7b;delayms(30);P2=0x77;delayms(30);P2=0x6f;delayms(30);P2=0x5f;delayms(30);P2=0x3f;delayms(30);}//P26void cdP25(){P3=0x7c;delayms(30);//P3=0xff;P2=0x3e;delayms(30);P2=0x3d;delayms(30);P2=0x3b;delayms(30);P2=0x37;delayms(30);P2=0x2f;delayms(30);P2=0x1f;delayms(30);}//P25void cdP24(){P3=0x78;delayms(30);//P3=0xff;P2=0x1e;delayms(30);P2=0x1d;delayms(30);P2=0x1b;delayms(30);P2=0x17;delayms(30);P2=0x0f;delayms(30);}//P24void cdP23(){P3=0x70;delayms(30);//P3=0xff;P2=0x0e;delayms(30);P2=0x0d;delayms(30);P2=0x0b;delayms(30);P2=0x07;delayms(30);}//P23void cdP22(){P3=0x60;delayms(30);//P3=0xff;P2=0x06;delayms(30);P2=0x05;delayms(30);P2=0x03;delayms(30);}//P22void cdP21(){P3=0x20;delayms(30);//P3=0xff;P2=0x02;delayms(30);P2=0x01;delayms(30);}//P21void cdP20(){P3=0x00;delayms(30);//P3=0xff;P2=0x00;delayms(30);}//P20void cdP10(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30) ;P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);P3=0xff;P1=0xff;P1=0x7f;delayms(30);P1=0xbf;delayms(30);P1=0xdf;delayms(30);P1=0xef;delayms(30);P1=0xf7;delayms(30);P1=0xfb;delayms(30);P1=0xfd;delayms(30);P1=0xfe;delayms(30);}//P10void cdP11(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30);P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);P3=0xff;P1=0x7e;delayms(30);P1=0xbe;delayms(30);P1=0xde;delayms(30);P1=0xee;delayms(30);P1=0xf6;delayms(30);P1=0xfa;delayms(30);P1=0xfc;delayms(30);}//P11void cdP12(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30);P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);P3=0xff;P1=0x7c;delayms(30);P1=0xbc;delayms(30);P1=0xdc;delayms(30);P1=0xec;delayms(30);P1=0xf4;delayms(30);P1=0xf8;delayms(30);}//P12void cdP13(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30);P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);P3=0xff;P1=0x78;delayms(30);P1=0xb8;delayms(30);P1=0xd8;delayms(30);P1=0xe8;delayms(30);P1=0xf0;delayms(30);}//P13void cdP14(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30);P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);P3=0xff;P1=0x70;delayms(30);P1=0xb0;delayms(30);P1=0xd0;delayms(30);P1=0xe0;delayms(30);}//P14void cdP15(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30);P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);P3=0xff;P1=0x60;delayms(30);P1=0xa0;delayms(30);P1=0xc0;delayms(30);}//P15void cdP16(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30);P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);P3=0xff;P1=0x40;delayms(30);P1=0x80;delayms(30);}//P16void cdP17(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30);P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);P3=0xff;P1=0x00;delayms(30);}//P17void cdP30(){P3=0x7f;delayms(30);P3=0xbf;delayms(30);P3=0xdf;delayms(30);P3=0xef;delayms(30);P3=0xf7;delayms(30);P3=0xfb;delayms(30);P3=0xfd;delayms(30);P3=0xfe;delayms(30);}//P30void cdP31(){P3=0x7e;delayms(30);P3=0xbe;delayms(30);P3=0xde;delayms(30);P3=0xee;delayms(30);P3=0xf6;delayms(30);P3=0xfa;delayms(30);P3=0xfc;delayms(30); }//P31void cdP32(){P3=0x7c;delayms(30);P3=0xbc;delayms(30);P3=0xdc;delayms(30);P3=0xec;delayms(30);P3=0xf4;delayms(30);P3=0xfb;delayms(30); }//P32void cdP33(){P3=0x78;delayms(30);P3=0xb8;delayms(30);P3=0xd8;delayms(30);P3=0xe8;delayms(30);P3=0xf0;delayms(30); }//P33void cdP34(){P3=0x70;delayms(30);P3=0xb0;delayms(30);P3=0xd0;delayms(30);P3=0xe0;delayms(30); }//P34void cdP35(){P3=0x60;delayms(30);P3=0xa0;delayms(30);P3=0xc0;delayms(30);}//P35void cdP36(){P3=0x40;delayms(30);P3=0x80;delayms(30);}//P36void cdP37(){P3=0x00;delayms(30);}//P37/*----------------------------------------------------------*/ void cd() //由下至上沉淀{cdP00();cdP10();cdP01();cdP11();cdP02();cdP12();cdP03();cdP13();cdP04();cdP14();cdP05();cdP15();cdP06();cdP16();cdP07();cdP17();cdP27();cdP30();cdP26();cdP31();cdP25();cdP32();cdP24();cdP33();cdP23();cdP34();cdP22();cdP35();cdP21();cdP36();cdP20();cdP37();delayms(500);Offall();delayms(300);Onall();delayms(300);Offall();delayms(300);Onall();delayms(300);}/*----------------------------------------------------------*/ void szsx() //左右同时生长(由上至下){Offall();P0=0xfe;delayms(50);P0=0xfc;delayms(50);P1=0xfe;delayms(50);P0=0xf8;delayms(50);P1=0xfc;delayms(50);P0=0xf0;delayms(50);P1=0xf8;delayms(50);P0=0xe0;delayms(50);P1=0xf0;delayms(50);P0=0xc0;delayms(50);P1=0xe0;delayms(50);P0=0x80;delayms(50);P1=0xc0;delayms(50);P0=0x00;delayms(50);P1=0x80;delayms(50);P2=0x7f;delayms(50);P1=0x00;delayms(50);P2=0x3f;delayms(50);P3=0xfe;delayms(50);P2=0x1f;delayms(50);P3=0xfc;delayms(50);P2=0x0f;delayms(50);P3=0xf8;delayms(50);P2=0x07;delayms(50);P3=0xf0;delayms(50);P2=0x03;delayms(50);P3=0xe0;delayms(50);P2=0x01;delayms(50);P3=0xc0;delayms(50);P2=0x00;delayms(50);P3=0x80;delayms(50);P3=0x00;delayms(50);}/*----------------------------------------------------------*/void szxs() //左右同时生长(由下至上){Offall();P3=0x7f;delayms(50);P2=0xfe;delayms(50);P3=0x3f;delayms(50);P2=0xfc;delayms(50);P3=0x1f;delayms(50);P2=0xf8;delayms(50);P3=0x0f;delayms(50);P2=0xf0;delayms(50);P3=0x07;delayms(50);P2=0xe0;delayms(50);P3=0x03;delayms(50);P2=0xc0;delayms(50);P3=0x01;delayms(50);P2=0x80;delayms(50);P3=0x00;delayms(50);P2=0x00;delayms(50);P1=0x7f;delayms(50);P0=0x7f;delayms(50);P1=0x3f;delayms(50);P0=0x3f;delayms(50);P1=0x1f;delayms(50);P0=0x1f;delayms(50);P1=0x0f;delayms(50);P0=0x0f;delayms(50);P1=0x07;delayms(50);P0=0x07;delayms(50);P1=0x03;delayms(50);P0=0x03;delayms(50);P1=0x01;delayms(50);P0=0x01;delayms(50);P1=0x00;delayms(50);P0=0x00;delayms(50);}/*----------------------------------------------------------*/void l1d() //1个灯转{P0=0xfe,P2=0x7f,P3=0x7f,P1=0x7f;delayms(50);P0=0xfd,P2=0xbf,P3=0xbf,P1=0xbf;delayms(50);P0=0xfb,P2=0xdf,P3=0xdf,P1=0xdf;delayms(50);P0=0xf7,P2=0xef,P3=0xef,P1=0xef;delayms(50);P0=0xef,P2=0xf7,P3=0xf7,P1=0xf7;delayms(50);P0=0xdf,P2=0xfb,P3=0xfb,P1=0xfb;delayms(50);P0=0xbf,P2=0xfd,P3=0xfd,P1=0xfd;delayms(50);P0=0x7f,P2=0xfe,P3=0xfe,P1=0xfe;delayms(50); }/*----------------------------------------------------------*/ void l2d() //2个灯转{P0=0xfc,P2=0x3f,P3=0x3f,P1=0x3f;delayms(50);P0=0xf9,P2=0x9f,P3=0x9f,P1=0x9f;delayms(50);P0=0xf3,P2=0xcf,P3=0xcf,P1=0xcf;delayms(50);P0=0xe7,P2=0xe7,P3=0xe7,P1=0xe7;delayms(50);P0=0xcf,P2=0xf3,P3=0xf3,P1=0xf3;delayms(50);P0=0x9f,P2=0xf9,P3=0xf9,P1=0xf9;delayms(50);P0=0x3f,P2=0xfc,P3=0xfc,P1=0xfc;delayms(50);P0=0x7e,P2=0x7e,P3=0x7e,P1=0x7e;delayms(50); }/*----------------------------------------------------------*/ void l3d() //3个灯转{P0=0xf8,P2=0x1f,P3=0x1f,P1=0x1f;delayms(50);P0=0xf1,P2=0x8f,P3=0x8f,P1=0x8f;delayms(50);P0=0xe3,P2=0xc7,P3=0xc7,P1=0xc7;delayms(50);P0=0xc7,P2=0xe3,P3=0xe3,P1=0xe3;delayms(50);P0=0x8f,P2=0xf1,P3=0xf1,P1=0xf1;delayms(50);P0=0x1f,P2=0xf8,P3=0xf8,P1=0xf8;delayms(50);P0=0x3e,P2=0x7c,P3=0x7c,P1=0x7c;delayms(50);P0=0x7c,P2=0x3e,P3=0x3e,P1=0x3e;delayms(50);}/*----------------------------------------------------------*/ void l4d() //4个灯转{P0=0xf0,P2=0x0f,P3=0x0f,P1=0x0f;delayms(50);P0=0xe1,P2=0x87,P3=0x87,P1=0x87;delayms(50);P0=0xc3,P2=0xc3,P3=0xc3,P1=0xc3;delayms(50);P0=0x87,P2=0xe1,P3=0xe1,P1=0xe1;delayms(50);P0=0xaf,P2=0xf0,P3=0xf0,P1=0xf0;delayms(50);P0=0x1e,P2=0x78,P3=0x78,P1=0x78;delayms(50);P0=0x3c,P2=0x3c,P3=0x3c,P1=0x3c;delayms(50);P0=0x78,P2=0x1e,P3=0x1e,P1=0x1e;delayms(50);}/*----------------------------------------------------------*/void l5d() //5个灯转{P0=0xe0,P2=0x07,P3=0x07,P1=0x07;delayms(50);P0=0xc1,P2=0x83,P3=0x83,P1=0x83;delayms(50);P0=0x83,P2=0xc1,P3=0xc1,P1=0xc1;delayms(50);P0=0x87,P2=0xe0,P3=0xe0,P1=0xe0;delayms(50);P0=0x0e,P2=0x70,P3=0x70,P1=0x70;delayms(50);P0=0x1c,P2=0x38,P3=0x38,P1=0x38;delayms(50);P0=0x38,P2=0x1c,P3=0x1c,P1=0x1c;delayms(50);P0=0x70,P2=0x0e,P3=0x0e,P1=0x0e;delayms(50);}/*----------------------------------------------------------*/void l6d() //6个灯转{P0=0xc0,P2=0x03,P3=0x03,P1=0x03;delayms(50);P0=0x81,P2=0x81,P3=0x81,P1=0x81;delayms(50);P0=0x03,P2=0xc0,P3=0xc0,P1=0xc0;delayms(50);P0=0x06,P2=0x60,P3=0x60,P1=0x60;delayms(50);P0=0x0c,P2=0x30,P3=0x30,P1=0x30;delayms(50);P0=0x18,P2=0x18,P3=0x18,P1=0x18;delayms(50);P0=0x30,P2=0x0c,P3=0x0c,P1=0x0c;delayms(50);P0=0x60,P2=0x06,P3=0x06,P1=0x06;delayms(50);}void main() //主函数,由于模块化设计,只要修改下面各模块的排列顺序和时间,就可以实现各种变化模式{while(1) //无限循环{cx();//一点点出现rja(); //渐暗Onall();delayms(100);Offall();delayms(100);Onall();delayms(180);Offall();delayms(180);Onall();delayms(180);Offall();delayms(300);Onall();delayms(300);rja(); //渐暗delayms(300);// for(x=10;x>0;x--)// ss(100);/* 闪烁20次,50ms */// //ls(); /* 正向流水*/rjl();Offall();delayms(100);zxsz(); /* 正向生长*/delayms(500);rja();//渐暗rzmzy(); //拖尾从上到下rzmyy(); //拖尾从下到上for(x=6;x>0;x--) /*P00闪烁6次50ms*/{P0=0xfe,delayms(50);P0=0xff,delayms(50);}szsx(); /* 半双边生长,由上至下*/rja();//渐暗for(x=10;x>0;x--)ss(100);/* 闪烁20次,50ms */Offall();rzmnwyd();delayms(100);//走马内外移动函数//l1d(),l2d(),l3d(),l4d(),l5d(),l6d(),Onall(),delayms(50);//1至6个灯转rja();//渐暗for(x=6;x>0;x--) /*P00闪烁6次50ms*/{P0=0xfe,delayms(50);P0=0xff,delayms(50);}bsb();//双边同时流水由上至下szxs(); /* 半双边生长,由下至上*/rja();//渐暗ss(100); /* 闪烁10次*/l1d(),l2d(),l3d(),l4d(),l5d(),l6d(),Onall(),delayms(50);//1至6个灯转l1d(),l2d(),l3d(),l4d(),l5d(),l6d(),Onall(),delayms(50);//1至6个灯转Onall();delayms(200);c(700),c(600),c(500);//间隔闪烁c(400),c(300),c(200);c(100),c(100),c(100),c(100);c(50),c(50),c(50),c(50);Offall();for(x=10;x>0;x--){ss(100);}/* 闪烁*/rzmzy(); //拖尾从上到下szxs();/* 半双边生长,由下至上*/szsx(); /* 半双边生长,由上至下*/rja(); //渐暗delayms(100);rzmzy(); //拖尾从上到下//fbsb();/* 半双边流水由下至上*/for(x=10;x>0;x--){P3=0x7f;delayms(50);Offall();delayms(50); /* P37闪烁6次,50ms */ }cd(); /* 由下至上沉淀*///fxsw(); /* 反向死亡*/rja(); //渐暗rzmyy(); //拖尾从下到上bsb();//双边同时流水由上至下// fxsz();Offall(); /* 反向生长*/szsx();/* 左右同时生长由上至下*/rja();delayms(200);for(x=20;x>0;x--){ss(100);} /* 闪烁20次*/rjl(); //渐亮delayms(500);rja(); //渐暗rzmyy(); //拖尾从下到上szsx(); /* 半双边生长,由上至下*/Offall();delayms(100);rjl(); //渐亮Offall();delayms(500); //开启所有灯2sfor(x=20;x>0;x--){c(100);} /* 闪烁20次*/l1d(),l2d(),l3d(),l4d(),l5d(),l6d(),Onall(),delayms(50);//1至6个灯转l1d(),l2d(),l3d(),l4d(),l5d(),l6d(),Onall(),delayms(50);//1至6个灯转for(x=3;x>0;x--){Onall();delayms(200);Offall();delayms(200);}Onall();delayms(500);rja(); //渐暗delayms(100);rzmzy(); //拖尾从上到下rzmyy(); //拖尾从下到上szsx();/* 左右同时生长由上至下*/delayms(300);rja(); //渐暗rjl(); //渐亮delayms(300);rzmnwyd(); //走马内外移动delayms(300);rja(); //渐暗delayms(300);rtbyd(); //眨眼rtbyd(); //眨眼Onall();delayms(180);Offall();delayms(180);Onall();delayms(180);Offall();delayms(180);Onall();delayms(500);Offall();delayms(300);szsx();/* 左右同时生长由上至下*/delayms(300);szsx();/* 左右同时生长由上至下*/rja();delayms(1000);Onall();delayms(2000);}}void rzmyy() //走马拖尾右移函数{Offall();delayms(200);P3=0x7f;delayms(60);P3=0xbf;P2=0xfe;if(P37==1){unsigned int a;for(a=0;a<350;a++) //调节点亮时间{unsigned char i;P37 = 0;for(i = 0; i < 15; i++); //调节亮度高低P37 = 1;for(i = 0; i < 50; i++);}}P3=0xdf;P2=0xfd;if(P36==1 && P20==1){unsigned int a;for(a=0;a<350;a++) //调节点亮时间{unsigned char i;P36 = 0;P20 = 0;for(i = 0; i < 15; i++); //调节亮度高低P37 = 0;for(i = 0; i < 1; i++); //调节亮度高低P36 = 1;P20 = 1;P37 = 1;for(i = 0; i < 50; i++);}}P3=0xef;P2=0xfb;if(P35==1 && P21 ==1){unsigned int a;for(a=0;a<350;a++) //调节点亮时间{unsigned char i;P35 = 0;P21 = 0;for(i = 0; i < 15; i++); //调节亮度高低{P36 = 0;P20 = 0;}for(i = 0; i < 1; i++); //调节亮度高低P35 = 1;P21 = 1;P36 = 1;P20 = 1;for(i = 0; i < 50; i++);}}P3=0xf7;P2=0xf7;if(P34==1 && P22 == 1){unsigned int a;for(a=0;a<350;a++) //调节点亮时间{unsigned char i;P34 = 0;P22 = 0;for(i = 0; i < 15; i++); //调节亮度高低{P35 = 0;P21 = 0;}for(i = 0; i < 1; i++); //调节亮度高低P34 = 1;P22 = 1;P35 = 1;P21 = 1;for(i = 0; i < 50; i++);}}P3=0xfb;P2=0xef;if(P33==1 && P23==1){unsigned int a;for(a=0;a<350;a++) //调节点亮时间{unsigned char i;P33 = 0;P23 = 0;for(i = 0; i < 15; i++); //调节亮度高低{P34 = 0;P22 = 0;for(i = 0; i < 1; i++); //调节亮度高低P33 = 1;P23 = 1;P34 = 1;P22 = 1;for(i = 0; i < 50; i++);}}P3=0xfd;P2=0xdf;if(P32==1 && P24==1){unsigned int a;for(a=0;a<350;a++) //调节点亮时间{unsigned char i;P32 = 0;P24 = 0;for(i = 0; i < 15; i++); //调节亮度高低{P33 = 0;P24 = 0;}for(i = 0; i < 1; i++); //调节亮度高低P32 = 1;P24 = 1;P33 = 1;P23 = 1;for(i = 0; i < 50; i++);}}P3=0xfe;//P3^0P2=0xbf;//P2^6if(P31==1 && P25==1){unsigned int a;for(a=0;a<350;a++) //调节点亮时间{unsigned char i;P31 = 0;P25 = 0;for(i = 0; i < 15; i++); //调节亮度高低P32 = 0;。

跑马灯--动态心形(汇编语言)

跑马灯--动态心形(汇编语言)

DELAY: MOV R3 , #08FH DJNZ R3 , $ DJNZ R2, DELAY MOV P1 , #0 INC R0 CJNE R0 , #8 , KKK MOV R0 , #0 DJNZ R4 , KKK INC DPTR INC R6 CJNE R6 , #08H, III MOV R6,#0 MOV DPTR,#200H SJMP III ORG 200H TAB: DB 0E3H, 0C1H, 081H,03H,03H,081H,0C1H, 0E3H, DB 0E3H, 0C1H ,081H,03H,03H,081H,0C1H, 0E3H END
程序编写:
CJNE R6 , #18H, III MOV R6, #0 MOV DPTR, #200H SJMP III ORG 200H 0FFH, 0FFH, 7DH, 01H, 01H, 7DH, 0FFH, 0FFH 0E3H, 0C1H ,81H, 03H, 03H, 81H, 0C1H, 0E3H 0FFH, 81H, 01H, 3FH, 3FH, 3FH, 01H, 81H 0FFH, 0FFH,7DH, 01H, 01H, 7DH, 0FFH,0FFH
利用IO口实现跑马灯功能: 跑马灯又称为流水灯。简单地说就是一 组灯在控制系统的控制下按照设定的时间和顺序 来发亮或熄灭,组成不同的图形,从而达到一定 的视觉效果。 • 基本跑马灯电路的组成: MCS—51单片机,LED小灯泡,电容电阻, 振荡电路,译码电路,光源电路等。
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 列置高电平 行置低电平
点阵共有64 个二极管每 个发光二极 管是放置在 行线和列线 的交叉点上
当对应的 某一列置 1电平, 某一行置 0电平, 则相应的 二极管就 亮
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include<reg52.h>#include <intrins.h>#define uint unsigned int#define uchar unsigned char//延时void delay(uint k){uint i,j;for(i=k;i--;i>0)for(j=100;j--;j>0);}void main(){uchar temp0,temp1;uchar yi;uchar yi0,yi1;uint i,j,k,a,b;j=k=a=b=3;//全部亮P0=P1=P2=P3=0x00;delay(700);P0=P1=P2=P3=0xff;//每个io口独自亮for(i=2;i--;i>0){P1=P0=0x00;delay(500);P1=P0=0xff;P3=P2=0x00;delay(500);P3=P2=0xff;}//全部亮,闪三次for(i=2;i--;i>0){P0=P1=P2=P3=0x00;delay(100);P0=P1=P2=P3=0xff;delay(100);}//P1、P2亮,P3、P0暗for(i=3;i--;i>0){P1=0x00,P2=0x00; P3=0xff,P0=0xff;delay(500);P1=0xff,P2=0xff,P3=0x00,P0=0x00;delay(500);}//四个点的流水while(j>0){temp0=0xfe,temp1=0x7f;P1=P3=temp0,P2=P0=temp1;delay(100);for(i=7;i--;i>0){temp0=_crol_(temp0,1),temp1=_cror_(temp1,1);P1=P3=temp0,P2=P0=temp1;delay(100);}j--;}//全部亮,闪三次for(i=3;i--;i>0){P0=P1=P2=P3=0x00;delay(300);P0=P1=P2=P3=0xff;delay(300);}//四个IO口同样跟踪流水while(k>0){temp0=0xfe,temp1=0x7f;P1=P3=temp0,P2=P0=temp1;delay(60);for(i=7;i--;i>0){temp0=temp0<<1,temp1=temp1>>1;P1=P3=temp0,P2=P0=temp1;delay(60);}k--;}P0=P1=P3=P2=0xff;while(k<3){temp0=0x7f,temp1=0xfe;P1=P3=temp0,P2=P0=temp1;delay(60);for(i=7;i--;i>0){temp0=temp0>>1,temp1=temp1<<1;P1=P3=temp0,P2=P0=temp1;delay(60);}k++;}P3=P2=0xff;//两边单个从上向下流水yi=0xfe;P1=P0=yi;delay(50);for(i=7;i--;i>0){yi=_crol_(yi,1);P1=P0=yi;delay(50);}P1=P0=0xff;yi=0xfe;P3=P2=yi;delay(50);for(i=7;i--;i>0){yi=_crol_(yi,1);P3=P2=yi;delay(50);}P3=P2=0Xff;//两边单个返回流水for(i=7;i--;i>0){yi=_cror_(yi,1);P3=P2=yi;delay(50);}P3=P2=0xff;for(i=7;i--;i>0){yi=_cror_(yi,1);P0=P1=yi;delay(50);}//全部亮,闪三次P0=P1=P3=P2=0xff;for(i=3;i--;i>0){P0=P1=P2=P3=0x00;delay(100);P0=P1=P2=P3=0xff;delay(100);}//流水灯yi0=0xfe,yi1=0x7f;P3=P2=yi1,P1=P0=yi0;delay(100);for(i=7;i--;i>0){yi0=yi0<<1, yi1=yi1>>1;P1=P0=yi0,P3=P2=yi1;delay(100);}P1=P2=P3=P0=0xff;delay(200);yi0=0x7f,yi1=0xfe;P1=P0=yi0,P3=P2=yi1;for(i=7;i--;i>0){yi0=yi0>>1,yi1=yi1<<1;P1=P0=yi0,P3=P2=yi1;delay(100);}//大循环跟踪流水P1=P2=P3=P0=0xff;for(i=8;i--;i>0){P1=P1<<1;delay(50);}for(i=8;i--;i>0){P3=P3<<1;delay(50);}for(i=8;i--;i>0){P2=P2>>1;delay(50);}for(i=8;i--;i>0){P0=P0>>1;delay(50);}//逆向大循环跟踪流水P1=P2=P3=P0=0xff;for(i=8;i--;i>0){P0=P0<<1;delay(50);}for(i=8;i--;i>0){P2=P2<<1;delay(50);}for(i=8;i--;i>0){P3=P3>>1;delay(50);}for(i=8;i--;i>0){P1=P1>>1;delay(50);}//全部亮,闪三次P0=P1=P3=P2=0xff;for(i=4;i--;i>0){P0=P1=P2=P3=0x00;delay(100);P0=P1=P2=P3=0xff;delay(100);}//全部亮,只有一个暗的在流水temp0=0x01,temp1=0x00;P1=P0=temp0,P3=P2=temp1;delay(100);for(i=7;i--;i>0){temp0=_crol_(temp0,1);P1=P0=temp0;delay(100);}P1=P0=0x00;temp1=0x01;P3=P2=temp1;delay(100);for(i=7;i--;i>0){temp1=_crol_(temp1,1);P3=P2=temp1;delay(100);}//全部亮,逆向一个暗在流水temp0=0x00,temp1=0x80;P1=P0=temp0,P3=P2=temp1;delay(100);for(i=7;i--;i>0){temp1=_cror_(temp1,1);P3=P2=temp1;delay(100);}P3=P2=0x00;temp0=0x80;P1=P0=temp0;delay(100);for(i=7;i--;i>0){temp0=_cror_(temp0,1);P1=P0=temp0;}//花样temp0=0xaa,temp1=0x55;P1=P3=temp0,P2=P0=temp1;delay(500);for(;a--;a>0){for(i=7;i--;i>0){temp0=_crol_(temp0,1),temp1=_cror_(temp1,1);P1=P3=temp0,P2=P0=temp1;delay(500);}}for(;b--;b>0){temp0=0xee,temp1=0x77;P1=P3=temp0,P2=P0=temp1;delay(300);for(i=7;i--;i>0){temp0=_crol_(temp0,1),temp1=_cror_(temp1,1);P1=P3=temp0,P2=P0=temp1;delay(300);}}//环形逐个亮P1=P2=P3=P0=0xff;for(i=8;i--;i>0){P0=P0<<1;delay(50);}for(i=8;i--;i>0){P2=P2<<1;delay(50);}for(i=8;i--;i>0){P3=P3>>1;}for(i=8;i--;i>0){P1=P1>>1;delay(50);}//逐个熄灭for(i=7;i--;i>0){P0=~P0<<1;P0=~P0;delay(50);}P0=0xff;for(i=7;i--;i>0){P2=~P2<<1;P2=~P2;delay(50);}P2=0xff;for(i=7;i--;i>0){P3=~P3>>1;P3=~P3;delay(50);}P3=0xff;for(i=7;i--;i>0){P1=~P1>>1;P1=~P1;delay(50);}P1=0xff;}如需仿真文件,和电路连接,请移步中国电子DIY之家论坛搜心形流水灯。

相关文档
最新文档