芯片解密,芯片破解,IC解密,单片机解密,MCU解密,STM解密

飞芯科技提供芯片解密,芯片破解,IC解密,单片机解密,MCU解密,STM解密逆向服务

软件开发STC15F2K60S2单片机指北针的设计

  1. 项  目:温、湿度测量程序软件开发STC15F2K60S
  2. 软件开发单片机:芯片破解STC15F2K60S
  3. 传感器:DHT11
  4. 日  期:04.09
  5. ************************************************/

  6. #include <stc12c5a60s2.h>
  7. #include "delay.h"

  8. #define uint unsigned int
  9. #define uchar unsigned char

  10. sbit io = P2^0;                        //定义数据端口

  11. uchar data_byte;                //定义全局变量
  12. uchar RH,RL,TH,TL;                //定义全局变量

  13. unsigned char code DuanMa[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};        // 显示段码值0~9
  14. uchar  TempData[5];                         //存储显示值的全局变量

  15. /******************** DHT11测试模块**********************/
  16. void start()                        //开始信号
  17. {
  18.         io=1;
  19.         delayus(10);
  20.         io=0;
  21.         delayms(30);                //10~60之间
  22.         io=1;
  23.         delayus(100);                //关键时间:35-250之间
  24. }

  25. /**********************接收一个字节**********************/
  26. uchar receive_byte()                       
  27. {
  28.         uchar i,temp,count;
  29.         for(i=0;i<8;i++)
  30.         {
  31.                 count=2;
  32.                 while((!io)&&count++)               
  33.                 temp=0;
  34.                 delayus(150);                                //关键时间:10~23之间
  35.                 if(io==1)temp=1;
  36.                 count=2;
  37.                 while((io)&&count++);
  38.                 if(count==1)break;
  39.                 data_byte<<=1;
  40.                 data_byte|=temp;
  41.         }
  42.         return data_byte;
  43. }

  44. /************************接收数据************************/

  45. void receive()                                       
  46. {
  47.         uchar T_H,T_L,R_H,R_L,check,num_check;
  48.         uchar count;

  49.         start();                                        //开始信号               
  50.         io=1;       
  51.         if(!io)                                                //读取DHT11响应信号
  52.         {
  53.                 count=2;
  54.                 while((!io)&&count++);        //DHT11高电平80us是否结束
  55.                 count=2;
  56.                 while((io)&&count++);               
  57.                 R_H=receive_byte();
  58.                 R_L=receive_byte();
  59.                 T_H=receive_byte();
  60.                 T_L=receive_byte();       
  61.                 check=receive_byte();
  62.                
  63.                 io=0;                                       
  64.                    delayms(1);                                //拉低延时               
  65.                 io=1;               
  66.                 num_check=R_H+R_L+T_H+T_L;
  67.                        
  68.                 if(num_check=check)
  69.                 {
  70.                         RH=R_H;
  71.                         RL=R_L;
  72.                         TH=T_H;
  73.                         TL=T_L;
  74.                         check=num_check;               
  75.                 }               
  76.         }
  77. }



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.taihedz.cn
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信