⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3726程序test.c

📁 SN3726的检测程序
💻 C
字号:

#define XMS 2000  /* 定时中断间隔 12MHz,1uS */ 
#include <reg51.h>
#include <stdio.h>
#define uchar unsigned char
#include <intrins.h>
#define nor _nop_();
#define uint unsigned int
sbit	en	=P0^0;  
sbit	latch	=P0^1; 
sbit	clock	=P0^2;  
sbit	sin	=P0^3; 
sbit  k1    =P3^2;
sbit  k2    =P3^3; 
uchar a;
uchar b;
bit i;
bit m;
uchar n;
uint l;

/*t=0.1ms*/
void delayms(unsigned int t)
{
uchar i;
while(t--)
	{
	i=100;
	while(i--);	
	}
}

void formate(uchar c,uchar d)
{
if ((c&d)==d)
i=1;
else
i=0;
sin=i;

nor;
nor;
nor;
nor;
nor;
nor;
nor;

clock=1;

nor;
nor;

clock=0;

nor;
nor;
nor;
nor;
nor;
nor;
nor;
}

void input(uchar a,uchar b)
{
nor;
nor;
nor;
nor;
nor;
nor;
nor;
nor;
nor;
nor;
nor;
nor;

/*开始送串行数据*/
/*送D16*/
formate(b,0x01);

/*送D15*/
formate(b,0x02);

/*送D14*/
formate(b,0x04);

/*送D13*/
formate(b,0x08);

/*送D12*/
formate(b,0x10);

/*送D11*/
formate(b,0x20);

/*送D10*/
formate(b,0x40);

/*送D9*/
formate(b,0x80);

/*-------------------------------------------*/

/*送D8*/
formate(a,0x01);

/*送D7*/
formate(a,0x02);

/*送D6*/
formate(a,0x04);

/*送D5*/
formate(a,0x08);

/*送D4*/
formate(a,0x10);

/*送D3*/
formate(a,0x20);

/*送D2*/
formate(a,0x40);

/*送D1*/
formate(a,0x80);
en=1;
nor;
nor;
latch=1;
nor;
nor;
nor;
nor;
nor;
latch=0;
nor;
nor;
en=0;
nor;
nor;
nor;
nor;
nor;

delayms(40);     /*200ms---------------------------------------------------------------------------------------------------*/
}


/* ***********循环亮 ************ */
void xunhuanliang ()
{
 b=0x00;

/*第一个灯亮0.2s*/
input(0x80,0x00);

/*前两个灯亮0.2s*/
input(0xc0,0x00);

/*前3个灯亮0.2s*/
input(0xe0,0x00);

/*前4个灯亮0.2s*/
input(0xf0,0x00);

/*前5个灯亮0.2s*/
input(0xf8,0x00);

/*前6个灯亮0.2s*/
input(0xfc,0x00);

/*前7个灯亮0.2s*/
input(0xfe,0x00);

/*前8个灯亮0.2s*/
input(0xff,0x00);

/*前9个灯亮0.2s*/
input(0xff,0x80);

/*前10个灯亮0.2s*/
input(0xff,0xc0);

/*前11个灯亮0.2s*/
input(0xff,0xe0);

/*前12个灯亮0.2s*/
input(0xff,0xf0);

/*前13个灯亮0.2s*/
input(0xff,0xf0);

/*前14个灯亮0.2s*/
input(0xff,0xfc);

/*前15个灯亮0.2s*/
input(0xff,0xfe);

/*前16个灯亮0.2s*/
input(0xff,0xff);


/*1灭0.2s*/
input(0x7f,0xff);

/*前2个灯灭0.2s*/
input(0x3f,0xff);

/*前3个灯灭0.2s*/
input(0x1f,0xff);

/*前4个灯灭0.2s*/
input(0x0f,0xff);

/*前5个灯灭0.2s*/
input(0x07,0xff);

/*前6个灯灭0.2s*/
input(0x03,0xff);

/*前7个灯灭0.2s*/
input(0x01,0xff);

/*前8个灯灭0.2s*/
input(0xff,0xff);

/*前9个灯灭0.2s*/
input(0xff,0x7f);

/*前10个灯灭0.2s*/
input(0xfea,0x3f);

/*前11个灯灭0.2s*/
input(0xfc,0x1f);

/*前12个灯灭0.2s*/
input(0xf8,0x0f);

/*前13个灯灭0.2s*/
input(0xf0,0x07);

/*前14个灯灭0.2s*/
input(0xe0,0x03);

/*前15个灯灭0.2s*/
input(0x00,0x01);

/*全灭0.2s*/
input(0x00,0x00);
}

/* *************  跟着亮 ***************  */
void genzheliang ()
{
/*第一个灯亮0.2s*/
input(0x80,0x00);

/*前两个灯亮0.2s*/
input(0xc0,0x00);

/*前3个灯亮0.2s*/
input(0xe0,0x00);

/*前4个灯亮0.2s*/
input(0xf0,0x00);

/*前5个灯亮0.2s*/
input(0xf8,0x00);

/*前6个灯亮0.2s*/
input(0xfc,0x00);

/*前7个灯亮0.2s*/
input(0xfe,0x00);

/*前8个灯亮0.2s*/
input(0xff,0x00);

/*前9个灯亮0.2s*/
input(0xff,0x80);

/*前10个灯亮0.2s*/
input(0xff,0xc0);

/*前11个灯亮0.2s*/
input(0xff,0xe0);

/*前12个灯亮0.2s*/
input(0xff,0xf0);

/*前13个灯亮0.2s*/
input(0xff,0xf8);

/*前14个灯亮0.2s*/
input(0xff,0xfc);

/*前15个灯亮0.2s*/
input(0xff,0xfe);

/*前16个灯亮0.2s*/
input(0xff,0xff);


/*1灭0.2s*/
input(0x7f,0xff);

/*前2个灯灭0.2s*/
input(0x3f,0xff);

/*前3个灯灭0.2s*/
input(0x1f,0xff);

/*前4个灯灭0.2s*/
input(0x0f,0xff);

/*前5个灯灭0.2s*/
input(0x07,0xff);

/*前6个灯灭0.2s*/
input(0x03,0xff);

/*前7个灯灭0.2s*/
input(0x01,0xff);

/*前8个灯灭0.2s*/
input(0x00,0xff);

/*前9个灯灭0.2s*/
input(0x00,0x7f);

/*前10个灯灭0.2s*/
input(0x00,0x3f);

/*前11个灯灭0.2s*/
input(0x00,0x1f);

/*前12个灯灭0.2s*/
input(0x00,0x0f);

/*前13个灯灭0.2s*/
input(0x00,0x07);

/*前14个灯灭0.2s*/
input(0x00,0x03);

/*前15个灯灭0.2s*/
input(0x00,0x01);

/*全灭0.2s*/
input(0x00,0x00);
}


/*左右两排,分别向上亮,亮到上面以后又一次暗下来*/
void liangpai()
{

/*中间0个*/
input(0x00,0x00);

/*中间2个*/
input(0x01,0x80);

/*中间4个*/
input(0x03,0xc0);

/*中间6个*/
input(0x07,0xe0);

/*中间8个*/
input(0x0f,0xf0);

/*中间10个*/
input(0x1f,0xf8);

/*中间12个*/
input(0x3f,0xfc);

/*中间14个*/
input(0x7f,0xfe);

/*中间16个*/
input(0xff,0xff);

/*中间14个*/
input(0x7f,0xfe);

/*中间12个*/
input(0x3f,0xfc);

/*中间10个*/
input(0x1f,0xf8);

/*中间8个*/
input(0x0f,0xf0);

/*中间6个*/
input(0x07,0xe0);

/*中间4个*/
input(0x03,0xc0);

/*中间2个*/
input(0x01,0x80);

/*中间0个*/
input(0x00,0x00);}



/*左右成菱形形状依次亮*/
void lingxing()
{

input(0x00,0x00);
delayms(100);

input(0x80,0x00);
delayms(100);
input(0x80,0x02);
delayms(100);
input(0xa0,0x02);
delayms(100);
input(0xa0,0x0a);
delayms(100);

input(0xa8,0x0a);
delayms(100);
input(0xa8,0x2a);
delayms(100);
input(0xaa,0x2a);
delayms(100);
input(0xaa,0xaa);
delayms(100);

input(0xab,0xaa);
delayms(100);
input(0xab,0xea);
delayms(100);
input(0xaf,0xea);
delayms(100);
input(0xaf,0xfa);
delayms(100);

input(0xbf,0xfa);
delayms(100);
input(0xbf,0xfe);
delayms(100);
input(0xff,0xfe);
delayms(100);
input(0xff,0xff);
delayms(100);

input(0xff,0xff);
delayms(100);
input(0xff,0xfe);
delayms(100);
input(0xbf,0xfe);
delayms(100);
input(0xbf,0xfa);
delayms(100);

input(0xaf,0xfa);
delayms(100);
input(0xaf,0xea);
delayms(100);
input(0xab,0xea);
delayms(100);
input(0xab,0xaa);
delayms(100);

input(0xaa,0xaa);
delayms(100);
input(0xaa,0x2a);
delayms(100);
input(0xa8,0x2a);
delayms(100);
input(0xa8,0x0a);
delayms(100);

input(0xa0,0x0a);
delayms(100);
input(0xa0,0x02);
delayms(100);
input(0x80,0x02);
delayms(100);
input(0x80,0x00);
delayms(100);
}

void shanshuo ()
{
input(0x00,0x00);

input(0x00,0x00);

input(0xff,0xff);

input(0xff,0xff);

}
/*左右分别从中间向两边亮*/
void zhongjian()
{
input(0x00,0x00);
delayms(150);

input(0x18,0x18);
delayms(100);
input(0x3c,0x3c);
delayms(100);
input(0x7e,0x7e);
delayms(100);
input(0xff,0xff);
delayms(100);

input(0x7e,0x7e);
delayms(100);
input(0x3c,0x3c);
delayms(100);
input(0x18,0x18);
delayms(100);
}


/*  外中断0  */
void int0() interrupt 0 using 1
{ 
 EA=0;
	if(n==5)
	n=0;
	else
	n++;
EA=1;
}


main()
{
IT0=1;
EX0=1;
EA=1;
n=0;
while(1)
	{
		if(n==0)
		{
			xunhuanliang();
		}

		else if(n==1)
		{
			liangpai();
		}

		else if(n==2)
		{
			lingxing();
		}

		else if(n==3)
		{
			shanshuo();
		}


		else if(n==4)
		{
			zhongjian();
		}

		else
		{
			genzheliang();
		}
	}
}
 


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -