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

📄 扫描.txt

📁 This is the tlc0834 driver, welcome everybody criticism to point out mistakes This is the tlc0834 dr
💻 TXT
字号:
#include <reg51.h>   //库函数

#include <absacc.h>
#include <stdio.h>

#define uint  unsigned int
#define uchar unsigned char


//////////////////////////////////////////////////////////

//P2.7 --Recieve LED1
//P2.6 --Recieve LED2
//P2.5 --Recieve LED3
//P2.4 --Recieve LED4 
//
//
//

sbit LED0=P1^7;
sbit LED1=P1^6;
sbit LED2=P1^5;
sbit LED3=P1^4;
sbit COM=P1^3;     //发出1ms的脉冲波
sbit Light=P1^2;       //指示有试剂条放入
bit  OK=0;          
uchar t,step=0;
bit  flag = 0;

void IRQ_T0(void)interrupt 1
{
  //COM=~COM;
  switch(step){
  case 0 : 
    LED0 = ~LED0; //第一盏等发脉冲光
    break;
  case 1 : 
    LED1 = ~LED1; //第二盏等发脉冲光
    break;
  case 2 : 
    LED2 = ~LED2; //第三盏等发脉冲光
    break;
  case 3 : 
    LED3 = ~LED3; //第四盏等发脉冲光
    break;
  default :
    break;
  }
  if(LED0 |LED1 |LED2 |LED3 )
  	flag = 1;
  else
  	flag = 0;
  	
  TH0=(65536-500)/256;
  TL0=(65536-500)%256;
  if(!(t--)){TR0=0;OK=1;}  //100次发送完毕?发送完OK标志位1
}
void main(void)
{ 
  bit temp,Light;
  uchar count=0;
  TMOD=0x11;
  TH0=(65536-500)/256;
  TL0=(65536-500)%256;
  TR0=1;
  ET0=1;
  EA=1;	

  t=100;
  TR0=1;
  LED0=1; 
  LED1=0;
  LED2=0;
  LED3=0;  	
  while(1)
  {	
    	 
    switch(step)
	{
	  case 0:
	    if(P2&0x80){temp=1;}    //判断第一盏灯有试剂条
		else if(temp&&flag){temp=0;count++;}	//有就计数
		if(OK)	 
        {
        t=100;step=1;
        LED1=0;LED2=0;LED3=0;
        TR0=1;
         if(count>80)         //当计数大于80次,就认为有试剂条
            {Light=1;count=0;}
        }
	    break;

	  case 1:
	  if(P2&0x40){temp=1;}   //判断第二盏灯
		else if(temp&&flag){temp=0;count++;}	//有就计数
		if(OK)	 
        {
        t=100;step=2;
        LED0=0;LED2=0;LED3=0;
        TR0=1;
        if(count>80) 
            {Light=1;count=0;}
        }
	    break;
	  case 2:
	  if(P2&0x20){temp=1;}
		else if(temp&&flag){temp=0;count++;}	//有就计数
		if(OK)	 
        {
        t=100;step=3;
        LED0=0;LED1=0;LED3=0;
        TR0=1;
        if(count>80)
            {Light=1;count=0;}
        }
	    break;
	  case 3:
	    if(P2&0x10){temp=1;}
		else if(temp&&flag){temp=0;count++;}	//有就计数
		if(OK)	 
        {
        t=100;step=0;
        LED0=0;LED1=0;LED2=0;
        TR0=1;
        if(count>80) 
            {Light=1;count=0;}
        }
	    break;
	  default :break;
	}
	 
  }
}


⌨️ 快捷键说明

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