Introduction: Automatic Door Opener Using CloudX Microcontroller and PIR Sensor

An Automatic Door Opener System is a simple project based on PIR Sensor and CloudX microcontroller, which automatically opens and closes the door by detecting a person or object. You must have seen automatic door openers in shopping malls and other commercial buildings. They open the door when someone comes near the entrance and close it after sometime.

A number of technologies are available to make such kinds of systems like PIR sensors, Radar sensors, Laser sensors, Infrared sensors, etc. In this project we will be using a PIR sensor.

In the Automatic Door Opening System, the main component or hardware is the sensor which detects the persons (well, the motion of the person in our case).

Let know more on PIR SENSOR.

Step 1: PIR Sensor

PIR sensor detects any change in heat, and whenever it detects any change, its output PIN becomes HIGH. They are also referred as Pyroelectric or IR motion sensors.

Here we should note that every object emits some amount of infrared when heated. Human also emits infrared because of body heat. PIR sensors can detect small amount of variation in infrared. Whenever an object passes through the sensor range, it produces infrared because of the friction between air and object, and get caught by PIR.

The main component of PIR sensor is Pyroelectric sensor shown in figure (rectangular crystal behind the plastic cap). Along with BISS0001 ("Micro Power PIR Motion Detector IC"), some resistors, capacitors and other components used to build PIR sensor. BISS0001 IC take the input from sensor and does processing to make the output pin HIGH or LOW accordingly.

Pyroelectric sensor divide in two halves, when there is no motion, both halves remain in same state, means both senses the same level of infrared. As soon as somebody enters in first half, the infrared level of one half becomes greater than other, and this causes PIRs to react and makes the output pin high.
Pyroelectric sensor is covered by a plastic cap, which has array of many Fresnel Lens inside. These lenses are curved in such a manner so that sensor can cover a wide range.

Step 2: L298N Motor Driver Module

Motor Driver is an important part of the project as it is responsible for driving the motor of the door (CD Tray Motor in this case). In this project, we have used the very common and very popular L298N Motor Driver Module.

Step 3: Components Required for Automatic Door Opener System

  • CloudX microcontroller
  • CloudX Softcard
  • V3 USB cable
  • PIR Sensor
  • L298N Motor Driver Module
  • CD Tray with 5v motor
  • Breadboard
  • Jumper wires

you can get component here

Step 4: Circuit Diagram

First, the Data OUT of the PIR Sensor is connected to Pin 1 of CloudX microcontroller. The other two pins of PIR Sensor i.e. Vs and GND are connected to +5V and GND respectively.

Coming to the Motor Driver, we have used the first channel of the L298N Motor Driver Module. Hence, the IN1 and IN2 of the L298N Motor Driver are connected to Pins 2 and 3 of CloudX microcontroller.

The Enable Pin of the Second Motor on the L298N Module us connected to +5V. Usually.

Since the motor used in the project is a 5V Motor, I’ve connected a 5V Supply to the Motor Driver Module.
The Motor of the CD Tray is connected to the OUT1 and OUT2 of L298N Motor Driver Module.

Step 5: Coding

copy this code to your CloudX IDE

#include <CloudX\M633.h>

#define PIR 1
           //setup here
    pinMode(PIR, INPUT);
    pinMode(2, OUTPUT);
    pinMode(3, OUTPUT);
           //Program here
    if (readPin(PIR) is HIGH){
            digitalWrite(2, HIGH);
            digitalWrite(3, LOW);
	    digitalWrite(2, LOW);
            digitalWrite(3, LOW);
            while(readPin(PIR) is HIGH);
	    digitalWrite(2, LOW);
            digitalWrite(3, HIGH);		
            digitalWrite(2, LOW);
            digitalWrite(3, LOW);
    else {
            digitalWrite(2, LOW);
            digitalWrite(3, LOW);