一、项目需求
二、代码实现
main.c
#include "reg52.h"
#include "InitSystem.h"
#include "SMGchek.h"
#include "LEDrun.h"
#include "Uart.h"
#include "KEY.h"
#include "Timer.h"
#include "ChooseHC138.h"
void Device_Detect()
{
LEDrun();
while(flag);
SMGchek();
ChooseHC138(YC0);
}
void main()
{
InitSystem();
Device_Detect();
InitTimer0();
InitUart();
while(1){
Select();
DisPlay_Time();
KEY();
}
}
LEDrun.h
#ifndef _LEDrun_H
#define _LEDrun_H
void Delay(unsigned char t);
void LEDrun();
extern unsigned char flag;
void Delay500ms();
#endif
LEDrun.c
#include "reg52.h"
#include "LEDrun.h"
#include <intrins.h>
#include "ChooseHC138.h"
unsigned char star = 1;
unsigned char flag = 1;
void Delay(unsigned char t)
{
while(t--);
}
void Delay500ms() //@11.0592MHz
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 22;
j = 3;
k = 227;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void LEDrun()
{
unsigned char i = 0;
ChooseHC138(YC4);
for(i=0;i<8;i++){
P0 = 0xff << i;
Delay500ms();
}
for(i=0;i<8;i++){
P0 = ~(0xff << i);
Delay500ms();
}
star = 0;
P0 = 0xff;
ChooseHC138(YC0);
flag = 0;
}
SMGchek.h
#ifndef _SMGchek_H
#define _SMGchek_H
void SMG_Display_Bit(unsigned char pos,