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 13 years, 5 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

  • Assistance locating a 'trail' camera gadget, please ? May 16, 2026
  • reviving old swordfish program but? May 16, 2026
  • Analog multiplexer has gone obselete May 16, 2026
  • Difference between TTL, RS232 and RS485 May 16, 2026
  • Smart Buoy project May 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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