[IAP15F2K61S2]工厂灯光控制系统

 一、项目需求

 二、代码实现

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,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值