EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Passive Infrared Sensor connected to 8051

Passive Infrared Sensor connected to 8051

|

Microcontroller › 8051 › Passive Infrared Sensor connected to 8051

  • This topic has 0 replies, 1 voice, and was last updated 12 years, 11 months ago by poovi.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • December 11, 2012 at 2:39 pm #3848
    poovi
    Participant

    HI,

    In my project, I am using a PIR sensor to control the lights. When I connect the sensor output to the ULN Driver (which is in turn connected to LEDs though relays), I was able to get proper working of the circuit. But when I use AT89C51 microcontroller to control the system i.e the PIR to the input of the microcontroller (say P2) and ULN driver connected to an output port (say P0), I was not able to get a proper response.  The LEDs would glow continuously when the reset switch on the microcontroller board was kept pressed.  The followinf is the code used. Please help me.

     

     

    #include <reg51.h>

    sbit pir_in=P2^6;        //PIR module's output pin
    sbit ULN_in1= P0^6;     //ULN input pin 1 LED1
    sbit ULN_in4= P0^4;    //ULN input pin 4 LED3

    int i,j,k;            //looping variables

    void init_delay (int a);     //to generate initial delay for the PIR to stabilise

    void main()
    {
    pir_in=1;                     //as input to microcontroller
    ULN_in1=0;         //as output
    ULN_in4=0;         //as output

    init_delay(120);     // 1 minute delay to activate the PIR module

    while(1)        //to continuously monitor PIR output
    {
    while(pir_in==1)
    {
    ULN_in1=1;          //because the ULN output is the inverse of the ULN input
    ULN_in4=1;
    }
    ULN_in1=0;
    ULN_in4=0;
    }
    }

    void init_delay (int a)
    {
    for(k=a;k>0;k–)
    for(i=0; i<1000; i++)
    for(j=0; j<1275; j++);
    }

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • JLCPBC are using a different shipping company = less $$$$$$$$ November 8, 2025
  • Help please! BLDC driver circuit using the IR2136s and the STP80NF06 MOSFETS November 8, 2025
  • need two ICs November 8, 2025
  • MLT-8530 Buzzer on ESP32: Why Is the Sound Output Lower Than Expected? November 8, 2025
  • Scope Clock CRT Z-Axis - Grid bias positive? November 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise