led心形流水灯程序(含各种效果应有尽有)

2020-01-21 21:31发布

本帖最后由 guohairui 于 2012-10-1 14:02 编辑

/*********************************************************
功能:改程序包含积点效果,顺、逆时针逐个点亮,顺、逆时针逐个
熄灭,对角亮灭,交叉亮灭,顺、逆时针逐段点亮,顺、逆时针逐段
熄灭等各种效果
连接线路为:P0^7-P0^0接灯1-8   //p0口接线与芯片引脚顺序相反方便焊接
            P1^0-P1^7接灯9-16        //其余引脚相同
                        P3^0-P3^7接灯17-24   
                        P2^0-P2^7接灯25-32
**********************************************************/
#include<reg52.h>
#include <intrins.h>

#define        uint unsigned int
#define        uchar unsigned char



/***********************************************************/
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 nzdl(uint t,uchar a);                   //逆时逐段亮
void nzdgl(uint t,uchar a);                  //逆时逐段一个点亮
void jgs(uint t,uchar a);                    //间隔闪
/***************************************************/

uchar code table[]={0xfe,0xfc,0xf8,0xf0,
0xe0,0xc0,0x80,0x00};                         // 逐个点亮0~7
uchar code table1[]={0x7f,0x3f,0x1f,0x0f,
0x07,0x03,0x01,0x00};                         // 逐个点亮7~0
uchar code table2[]={0x01,0x03,0x07,0x0f,
0x1f,0x3f,0x7f,0xff};                          // 逐个灭0~7
uchar code table3[]={0x80,0xc0,0xe0,0xf0,
0xf8,0xfc,0xfe,0xff};                           // 逐个灭7~0
uint code display_P0[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,   
0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7E,      //P0--》P3逐个堆积点亮部分的P0 堆积点亮


0x7D,0x7B,0x77,0x6F,0x5F,0x3F,0x3F,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,


0x3E,0x3D,0x3B,0x37,0x2F,0x1F,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,

0x1E,0x1D,0x1B,0x17,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,

0x0E,0x0D,0x0B,0x07,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,

0x06,0x05,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,

0x02,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,

0x00,0x00,0x00,

0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,

                     //P0 口显示内容

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,


/*0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,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x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,

0x00,0x00,0x00,

0x00,0x00,

0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,


/*0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,   */

};

/****************************************************************************/
uint code display_P2[]={
0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,           //P0--》P3逐个堆积点亮部分的P0 流水点亮
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,           //P0  全灭等待        0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7E,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,   
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,         
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,         
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,   
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,         
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,         
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,           
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,                       
0xFF,0xFF,0xFF,0xFF,0xFF,0xF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 堆积点亮
0x7E,0xBE,0xDE,0xEE,0xF6,0xFA,0xFC,
0x7C,0xBC,0xDC,0xEC,0xF4,0xF8,
0x78,0xB8,0xD8,0xE8,0xF0,
0x70,0xB0,0xD0,0xE0,
0x60,0xA0,0xC0,
0x40,0x80,
0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                       //P0 亮灭闪烁
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,    //P0--》P3间隔点亮部分的P0 1,3,5,7 亮。2,4,6,8灭
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
*/
};        

/**************************************************************/

uint code display_P3[]={       
0xFF,0xFF,0xFF,0xF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7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,

0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,
0x7E,0xBE,0xDE,0xEE,0xF6,0xFA,0xFC,

0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
0x7C,0xBC,0xDC,0xEC,0xF4,0xF8,

0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,
0x78,0xB8,0xD8,0xE8,0xF0,

0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0x70,0xB0,0xD0,0xE0,

0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0x60,0xA0,0xC0,

0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0x40,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,
0x00,0x00,
0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,


/*
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,    //P0--》P3间隔点亮部分的P0 1,3,5,7 亮。2,4,6,8灭
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
*/
};
      

/**********************************************************/
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;
                  delay(t);       
                  }
                  P2=0x00;P1=0xfe;
                  delay(t);

                  for(i=0;i<7;i++)
                  {
                          P1=table[i+1];
                        P3=table1;
                        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;
                        delay(t);
                }
                for(i=0;i<8;i++)
                {
                        P1=table;
                        delay(t);
                }
                for(i=0;i<8;i++)
                {
                        P3=table;
                        delay(t);
                }
                for(i=0;i<8;i++)
                {
                        P2=table;
                        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;delay(t);       
                }
                for (i=0;i<8;i++)
                {
                        P1=table2;delay(t);       
                }
                for (i=0;i<8;i++)
                {
                        P3=table2;delay(t);       
                }
                for (i=0;i<8;i++)
                {
                        P2=table2;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;
                        P1=P2=P3=table1;
                        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;
                        P1=P2=P3=table;
                        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;
                        P1=P2=P3=table3;
                        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;
                        P1=P2=P3=table2;
                        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;
                        P3=table;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;
                        P3=table2;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;
                        delay(t);
                }
                P0=0xff;
                for(i=0;i<8;i++)
                {
                        P1=table;
                        delay(t);
                }
                P1=0xff;
                for(i=0;i<8;i++)
                {
                        P3=table;
                        delay(t);
                }
                P3=0xff;
                for(i=0;i<8;i++)
                {
                        P2=table;
                        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 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;delay(t);       
                }
                for (i=0;i<8;i++)
                {
                        P3=table3;delay(t);       
                }
                for (i=0;i<8;i++)
                {
                        P1=table3;delay(t);       
                }
                for (i=0;i<8;i++)
                {
                        P0=table2;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;
                        delay(t);
                }
                for(i=0;i<8;i++)
                {
                        P3=table1;
                        delay(t);
                }
                for(i=0;i<8;i++)
                {
                        P1=table1;
                        delay(t);
                }
                for(i=0;i<8;i++)
                {
                        P0=table;
                        delay(t);
                }
        }


}
void delayms(uint ms)                                //延时子程序
{
  uint k;                                          
  while(ms--)
  {
    for(k = 0; k <100; k++);
  }
}

void delay(uint t)         
{
        uint x,y;
        for (x=t;x>0;x--)
        {
                for (y=120;y>0;y--);
        }
}
/****************************************************/


void main()
{
        uint g,i;

        while(1)
        {
         zg(100,1);                         //两边逐个亮
         lbzgm(100,1);                 //两边逐个灭
         jgs(300,10);
         djs(100,20);        //对角闪
        for(g=0;g<546; g++)   //积点效果   
    {
       P2 =display_P2[g];       
       P3 =display_P3[g];
           P1 =display_P1[g];
           P0 =display_P0[g];
      delayms(40);
    }

        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);
         }

   nzdl(200,3); //逆时逐段亮
   jgs(50,100);   //间隔闪


       
        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<1;i++)
        {
         zgxh(100,1);
         sszgm(100,1);
         }
        for(i=0;i<1;i++)
        {
         zgxh1(100,1);
         nszgm(100,1);
         }
        for(i=0;i<1;i++)
        {
         zgxh(100,1);
         sszgm(100,1);
         }
        for(i=0;i<1;i++)
        {
         zgxh1(100,1);
         nszgm(100,1);
         }
                 for(i=0;i<1;i++)
        {
         zgxh(100,1);
         sszgm(100,1);
         }
        for(i=0;i<2;i++)
        {
         zgxh1(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<5;i++)
        {
         zgxh(100,1);
         nszgm(100,1);
         }
         djs(100,20);  //对角闪
         zg(300,1);
         lbzgm(300,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);



        }
               
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
39条回答
sidu320
1楼-- · 2020-01-26 12:36
lxa0 发表于 2015-1-4 19:50
完全可以的~~~~~~~~~~~~~~~

那么多灯的话,电流跟的上吗?
lxa0
2楼-- · 2020-01-26 13:41
 精彩回答 2  元偷偷看……
7nian
3楼-- · 2020-01-26 13:50
程序还是打包上传的好,看着书真心累。

一周热门 更多>