标题: hc-sr501人体红外模块arduino与单片机程序源码 [打印本页]

作者: 火虫陌    时间: 2018-3-19 12:08
标题: hc-sr501人体红外模块arduino与单片机程序源码
hc-sr501人体红外模块介绍与电路原理图,附件里面包含arduino平台和51单片机源程序


单片机源程序如下:

  1. /*********************************************************************************************
  2. The name of the program: <Pyroelectric sensor module>     
  3. Date:  2012 04 09
  4. hardware:mcu(stc12c5a60s2),Operational Amplifier(lm324),Pyroelectric sensor module,etc
  5.                                                                
  6. /*********************************************************************************************/

  7. #include<stc12c5a60s2.h>  
  8. #define uchar unsigned char
  9. #define uint unsigned int
  10. /*********************************************************************************************/
  11. void Delay_us(unsigned int x)
  12. {
  13.         while(x--);
  14. }
  15. /*********************************************************************************************/
  16. void delay(int x)
  17. {
  18.         uchar i,j;
  19.         for(i=0;i<x;i++)
  20.                 for(j=0;j<110;j++);
  21. }
  22. /*********************************************************************************************/
  23. void ADC_one()       //Only channel P1.0
  24. {
  25.         P1ASF=0x1f;   
  26.         ADC_CONTR=0x00;
  27.         AUXR1=0x00;               
  28.         ADC_CONTR=0x80;
  29.         Delay_us(2);
  30.         ADC_CONTR=0x88;     
  31.         Delay_us(2);
  32.         while(ADC_CONTR==0x88);
  33.         ADC_CONTR=0;     
  34. }
  35. /*********************************************************************************************/

  36. void main()
  37. {       
  38.         while(1)
  39.         {
  40.                 float num=0;
  41.                 uint resl=0;
  42.                 ADC_one();            
  43.                 resl=ADC_RES;
  44.                 resl=(resl<<2)+ADC_RESL;
  45.                 num=resl/1024.0*5;   
  46.                 num=num*1000;

  47.                 if(num>2700)
  48.                 {
  49.                         P2=0XEF;//Light-emitting diode is lit
  50.                 }
  51.                 else
  52.                         P2=0XFF;        //Light-emitting diode is extinguished
  53.         }       
  54. }
  55. /*********************************************************************************************/
复制代码

所有资料51hei提供下载:
HC-SR501 人体红外感应模块 热释电 红外传感器 探头 .rar (2.62 MB, 下载次数: 47)



作者: 1677844682    时间: 2018-4-3 22:00
为什么那么多错误,用keil 4编译,
作者: yzzz    时间: 2018-4-27 22:48
请问51单片机源程序是哪一部分啊,本人单片机小白求指导,谢谢楼主~




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1