您好,欢迎访问欧洲杯竞猜入口官网!
17385464037
18798802230
欧洲杯竞猜入口
您的位置: 首页>>技术中心

技术中心

联系我们

欧洲杯竞猜入口

地址:贵州省贵阳市乌当区高新路205号
电话:17385464037

咨询热线 18798802230

爆闪灯源码解析

发布时间:2022-11-18 人气: 14

#include "pic.h"

#define uchar unsigned char

#define uint  unsigned int

//__CONFIG(0xff3);


#define DIGITKEY  RA0

uchar LEDFLASH_Type=0;

uchar i=0;


void System_Init(void);

void Process_Key(void);

void Led_Display(void);


void LED_Delay(uint j);


const uchar LEDCODE0[]={0x5a,0x5a,0x5a,0x5a,0xa5,0xa5,0xa5,0xa5,};

const uchar LEDCODE1[]={0xf0,0xf0,0xf0,0xf0,0x0f,0x0f,0x0f,0x0f,};

const uchar LEDCODE2[]={0xe7,0xe7,0xe7,0xe7,0xdb,0xdb,0xdb,0xdb,

0xbd,0xbd,0xbd,0xbd,0x7e,0x7e,0x7e,0x7e,};



void main()

{

System_Init();


     while(1)

{

Process_Key();

            Led_Display();

}

}



void System_Init()

{

  TRISA=0x01;

  RA0=1;

  TRISB=0x00;

  PORTB=0x00;

}


void Process_Key()

 if(0==DIGITKEY)

  { LED_Delay(10);

    if(0==DIGITKEY)

{  LEDFLASH_Type++;

if(LEDFLASH_Type==3)LEDFLASH_Type=0;

         }

while(0!=DIGITKEY){Led_Display();}

   }

}


void Led_Display()

{uchar k; 

switch(LEDFLASH_Type)

{

case 0: for(i=0;i<sizeof(LEDCODE0);i++)

    {

PORTB=LEDCODE0[i];

LED_Delay(100);

                        PORTB=0xff;

                        LED_Delay(50);

}

break;

case 1: for(i=0;i<sizeof(LEDCODE1);i++)

        { 

PORTB=LEDCODE1[i];

LED_Delay(100);

                        PORTB=0xff;

                        LED_Delay(50);

}

                    break;

case 2:for(i=0;i<sizeof(LEDCODE2);i++)

{

PORTB=LEDCODE2[i];

LED_Delay(100);

                        PORTB=0xff;

                        LED_Delay(50);

}

                   break;


         

 

          }

  }



void LED_Delay(uint j)

{

uint a,b;

    for(a=j;a>0;a--)

     for(b=65;b>0;b--);

}


推荐资讯


18798802230

贵公网安备 52011202003543号