欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 計數對射傳感器 [打印本頁]

作者: A-阿鵬    時間: 2017-11-20 14:37
標題: 計數對射傳感器
誰有這一類的教程或程序,急求   謝謝


作者: cccc8888    時間: 2017-11-20 16:39
基于AT89 S51的雙紅外激光對射開關實現智能照明控制.rar (342.53 KB, 下載次數: 10)


名字:基于AT89 S51的雙紅外激光對射開關實現智能照明控制

作者: gao915440792    時間: 2019-5-19 15:10
#include<reg51.h>
#include "uart.c"
#define uchar unsigned char
#define uint  unsigned int
//定義管腳
sbit key_1=P1^0; //計數
sbit key_2=P1^2;//頁面上翻
sbit key_3=P1^1;//頁面下翻
sbit key_4=P1^3;//清零
sbit key_5=P1^4;//回到計數模式
//--定義全局變量--//
unsigned char code wei[4] = {
0xfe,0xfd,0xfb,0xf7};//位選控制   查表的方法控制
unsigned char code duan[18] = {
0x5f,0x44,0x9d,0xd5,0xc6,0xd3,0xdb,0x47,0xdf,0xd7,0xcf,0xda,0x1b,0xdc,0x9b,0x8b,0x80};
//0、1、2、3、4、5、6、7、8、9、A、b、C、d、E、F的顯示碼
uchar count,yemian,number;//分別用來記錄當前數值,顯示的頁面  以及將記錄寫到數組的哪個位置
uchar record[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void display(uchar a,uchar b,uchar c); //動態顯示函數
void delay(unsigned int ms)//延時1毫秒(不夠精確的)
{
    unsigned int i,j;
    for(i=0;i<ms;i++)
    for(j=0;j<110;j++);
}
void key()
{
  if(key_1==0)
  {
   delay(5);
   if(key_1==0)
   {
    count++;
if(count>98)
count=99;
while(key_1==0)
display(yemian,count,record[yemian-1]);
   }
  }
  if(key_2==0)
  {
   delay(5);
   if(key_2==0)
   {
    if(yemian>1)
    yemian--;
else
yemian=15;
while(key_2==0)
display(yemian,count,record[yemian-1]);
   }
  }
  if(key_3==0)
  {
   delay(5);
   if(key_3==0)
   {
    if(yemian<15)
yemian++;
else
yemian=1;
while(key_3==0)
display(yemian,count,record[yemian-1]);
   }
  }
  if(key_4==0)
  {
    delay(5);
if(key_4==0)
{
  if(count!=0&&number<15)
  {
  record[number++]=count;
  
  }
  count=0;
  while(key_4==0)
  display(yemian,count,record[yemian-1]);
}
  }
  if(key_5==0)
  {
   delay(5);
   if(key_5==0)
   {
    yemian=0;
while(key_5==0)
display(yemian,count,record[yemian-1]);
   }
  }
}
/*******************************************************************************
* 函 數 名         : main
* 函數功能     : 主函數
* 輸    入         : 無
* 輸    出         : 無
*******************************************************************************/
void main(void)
{
    uchar i;
Uart_init();
while(1)
{
     
     for(i=0;i<15;i++)
  {
  display(yemian,count,record[yemian-1]);
  key();
  if(i==0)
  SendASC('$');
  display(yemian,count,record[yemian-1]);
  SendASC(record[i]/10+0x30);
  display(yemian,count,record[yemian-1]);
  SendASC(record[i]%10+0x30);

  }
  display(yemian,count,record[yemian-1]);
     SendASC(count/10+0x30);
  display(yemian,count,record[yemian-1]);
  SendASC(count%10+0x30);
  display(yemian,count,record[yemian-1]);
  SendASC('!');
  display(yemian,count,record[yemian-1]);
}   
}
/*******************************************************************************
* 函 數 名         : DigDisplay
* 函數功能     : 使用數碼管顯示
* 輸    入         : 無
* 輸    出         : 無
*******************************************************************************/
void display(unsigned char a,unsigned char b,uchar c)
{
P2=0x7f;
if(a!=0)
P0=~duan[a];
else
P0=~0x00;
delay(5);
P0=~0x00;
P2=0xbf;
if(a!=0)
P0=~duan[16];
else
P0=~0x00;
delay(5);
  P0=~0x00;
P2=0xdf;
if(a!=0)
P0=~duan[c/10];
else
P0=~duan[b/10];
delay(5);
P0=~0x00;
P2=0xef;
if(a!=0)
P0=~duan[c%10];
else
P0=~duan[b%10];
delay(5);
P0=~0x00;
}



作者: gao915440792    時間: 2019-5-19 15:11
#include<reg51.h>
#include "uart.c"
#define uchar unsigned char
#define uint  unsigned int

//定義管腳
sbit key_1=P1^0; //計數
sbit key_2=P1^2;//頁面上翻
sbit key_3=P1^1;//頁面下翻
sbit key_4=P1^3;//清零
sbit key_5=P1^4;//回到計數模式

//--定義全局變量--//
unsigned char code wei[4] = {
0xfe,0xfd,0xfb,0xf7};//位選控制   查表的方法控制
unsigned char code duan[18] = {
0x5f,0x44,0x9d,0xd5,0xc6,0xd3,0xdb,0x47,0xdf,0xd7,0xcf,0xda,0x1b,0xdc,0x9b,0x8b,0x80};
//0、1、2、3、4、5、6、7、8、9、A、b、C、d、E、F的顯示碼
uchar count,yemian,number;//分別用來記錄當前數值,顯示的頁面  以及將記錄寫到數組的哪個位置
uchar record[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void display(uchar a,uchar b,uchar c); //動態顯示函數
void delay(unsigned int ms)//延時1毫秒(不夠精確的)
{
    unsigned int i,j;
    for(i=0;i<ms;i++)
    for(j=0;j<110;j++);
}
void key()
{
  if(key_1==0)
  {
   delay(5);
   if(key_1==0)
   {
    count++;
        if(count>98)
        count=99;
        while(key_1==0)
        display(yemian,count,record[yemian-1]);
   }
  }

  if(key_2==0)
  {
   delay(5);
   if(key_2==0)
   {
    if(yemian>1)
    yemian--;
        else
        yemian=15;
        while(key_2==0)
        display(yemian,count,record[yemian-1]);
   }
  }

  if(key_3==0)
  {
   delay(5);
   if(key_3==0)
   {
    if(yemian<15)
        yemian++;
        else
        yemian=1;
        while(key_3==0)
        display(yemian,count,record[yemian-1]);
   }
  }

  if(key_4==0)
  {
    delay(5);
        if(key_4==0)
        {
         if(count!=0&&number<15)
         {
         record[number++]=count;
         
         }
         count=0;
         while(key_4==0)
         display(yemian,count,record[yemian-1]);
        }
  }

  if(key_5==0)
  {
   delay(5);
   if(key_5==0)
   {
    yemian=0;
        while(key_5==0)
        display(yemian,count,record[yemian-1]);
   }
  }
}
/*******************************************************************************
* 函 數 名         : main
* 函數功能                   : 主函數
* 輸    入         : 無
* 輸    出         : 無
*******************************************************************************/

void main(void)
{       
           uchar i;
        Uart_init();
        while(1)
        {
            
            for(i=0;i<15;i++)
                {
                display(yemian,count,record[yemian-1]);
                key();
                if(i==0)
                SendASC('$');
                display(yemian,count,record[yemian-1]);
                SendASC(record[i]/10+0x30);
                display(yemian,count,record[yemian-1]);
                SendASC(record[i]%10+0x30);
       
                }
                display(yemian,count,record[yemian-1]);
            SendASC(count/10+0x30);
                display(yemian,count,record[yemian-1]);
                SendASC(count%10+0x30);
                display(yemian,count,record[yemian-1]);
                SendASC('!');
                display(yemian,count,record[yemian-1]);
        }                               
}

/*******************************************************************************
* 函 數 名         : DigDisplay
* 函數功能                   : 使用數碼管顯示
* 輸    入         : 無
* 輸    出         : 無
*******************************************************************************/

void display(unsigned char a,unsigned char b,uchar c)
{
        P2=0x7f;
        if(a!=0)
        P0=~duan[a];
        else
        P0=~0x00;
        delay(5);
        P0=~0x00;
        P2=0xbf;
        if(a!=0)
        P0=~duan[16];
        else
        P0=~0x00;
        delay(5);
         P0=~0x00;
        P2=0xdf;
        if(a!=0)
        P0=~duan[c/10];
        else
        P0=~duan[b/10];
        delay(5);
        P0=~0x00;
        P2=0xef;
        if(a!=0)
        P0=~duan[c%10];
        else
        P0=~duan[b%10];
        delay(5);
        P0=~0x00;
}
作者: 是的哇    時間: 2019-5-19 17:58
代碼我跑過一遍,可以運行,很牛逼!!!!
作者: 提拉米蘇蘇    時間: 2019-5-19 21:40
支持分享!




歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1