Arduino Motion Sensor

Arduino Motion Sensor
Arduino Motion Sensor

Hi DIYer! Ever wanted to tryArduino Motion Sensor Luckily, this beginner’s guide covers that. No worries if you’re new to Arduinos—we’ll start with the board, motion sensor module, jumper wires, and breadboard. From there, we’ll step-by-step assemble the circuit. You’ll also learn how to upload Arduino code to detect motion. You’ll finish with a motion-sensing Arduino project you can develop on! This beginner’s tutorial to Arduino motion detection offers all you need.

Introduction to Arduino Motion Sensors

Motion sensors or detectors detect movement or presence in a room. Motion sensors are crucial to home automation and security. They may detect intruders or turn on lights when you enter. DIY electronics projects often employ the Arduino Uno microcontroller board. It can easily be used with motion sensors to make motion-activated devices.

Motion PIR Sensor

Common motion sensors include passive infrared (PIR) sensors. It detects infrared radiation from objects and movements when a warm body, like a human or animal moves in front of it. PIR sensors are cheap, easy to use, and radiation-free. Since they can sense minor temperature changes, they perform best indoors. An Arduino and PIR sensor may create a motion-activated security light or alarm.

Ultrasonic Sensor

When ultrasonic sensors emit high-frequency sound waves, they detect the reflection time. It can detect movement by monitoring sound wave fluctuations. An Arduino may have trouble setting up ultrasonic sensors, which have a larger range than PIR sensors. They work on motion-activated sprinklers and parking sensors indoors and outdoors.

Microwave Motion Sensor

Microwave motion sensors detect reflected microwave radiation from objects. They are sensitive and accurate, with a 10–25-foot range. Microwave sensors use more electricity than PIR or ultrasonic sensors and generate dangerous microwave radiation. Many commercial security systems and motion-activated doors use them. Many DIY Arduino projects don’t need microwave sensors, therefore PIR or ultrasonic sensors are better.

With an Arduino Uno and the correct motion sensor, you may make many home motion-activated devices. Options abound! Which motion sensor do you want for your next Arduino project?

Motion Sensor Selection for Arduino Projects

There are several Arduino motion detectors. Choose a sensor based on the size of the region you want to monitor, your budget, and detection precision.

A PIR sensor

PIR sensors are popular, affordable motion detectors. Heat from people and animals within its detecting range is detected. PIR sensors are straightforward to set up and detect movement within a room or region, but not through walls or glass. Their precision is low, sensing broad motion rather than specific movements. PIR sensors are inexpensive for basic needs.

Ultrasonic Sensor

Ultrasonic sensors detect movement by emitting high-frequency sound waves and detecting the echo. They are more precise than PIR sensors and can detect motion through walls and glass. Ultrasonic sensors are more expensive, harder to set up, and can’t detect little movements. They thrive in open, unobstructed spaces. Ultrasonic sensors are ideal for long-range, accurate detection.

Microwave Sensor

Microwave sensors detect doppler shifts from microwave signals reflected off moving objects. An Microwave sensors can precisely detect through walls and glass like ultrasonic sensors. They also cost more and are harder to deploy. Microwave sensors excel in high-security detecting systems that require accuracy. Microwave sensors are overkill for most hobbyists.

For a basic Arduino motion sensor, use a PIR sensor. For greater capabilities, use an ultrasonic or microwave sensor. Choose a sensor that fits your demands and skills to deploy it properly. Your next Arduino project can use a motion sensor among the many alternatives.

Arduino Motion Sensor Wiring

To detect motion using Arduino, wire up a motion sensor. PIR sensors are most frequent. These detect infrared light from persons and things.

Connecting PIR Sensor

Arduino PIR sensor connection is simple. PIR sensors feature power, ground, and signal pins. The power pin should be connected to Arduino’s 5V pin, ground to ground, and signal to digital pin 2.

Sensitivity Adjustment

PIR sensors have potentiometers for sensitivity adjustment. Turn clockwise to enhance sensitivity, counterclockwise to decrease. Start with middle sensitivity. Your sensor can then be tested and adjusted. It detects motion farther away but is more prone to mistakenly trigger with higher sensitivity. Lower sensitivity requires closer motion detection but fewer false alarms. Find your equilibrium.

Sensor testing

Upload a simple motion-detection sketch to test your PIR sensor after wiring it up. Something like this.

• LED on pin 13 • SensorUsing pin 2 as a PIR sensor: int sensorSensor state = 0;

In void setup(), pinMode(ledPin, OUTPUT) and sensorPin, INPUT) are set.

void loop() { sensorState = digitalRead(sensorPin); if (sensorState == HIGH) { digitalWrite(ledPin, HIGH); } turn on LED otherwise { digitalWrite(ledPin, LOW); // Turn off LED }

This turns on pin 13’s LED when motion is detected. Test your sensor’s LED by walking in front of it. Finalize sensitivity and positioning to your liking. The PIR motion sensor is now ready to detect movement and activate Arduino operations!

To detect motion using Arduino, connect the motion sensor.
Start with an Arduino Uno, a PIR motion sensor, and jumper wires. Pins to connect the motion sensor to Arduino: • Red to 5V • Black to GND • Yellow to digital pin 2

Writing Code

You may now program your Arduino to respond to motion. Enter the following code in Arduino IDE:

Int ledPin = 13; // LED on digital pin 13 int motionSensor = 2; // motion sensor on pin 2 int sensorState = 0; // sensor state variable

function setup() { pinMode(ledPin, OUTPUT); // LED output pinMode(motionSensor, INPUT); // sensor input

In void loop(), sensorState = digital.get(motionSensor); // get sensor values if (sensorState == HIGH) { @check for motion detection digitalDigitalWrite(ledPin, HIGH); // turn LED on } otherwise { digitalWrite(ledPin, LOW); // turn LED off }

How Works

This code continuously monitors the motion sensor. When motion is detected (sensor goes HIGH), pin 13’s LED turns on. No motion (sensor LOW) switches off the LED.

Upload this code to your Arduino to see the LED turn on when the sensor detects motion. Congratulations on your Arduino motion-activated system!

You can trigger buzzers, cameras, and alarms from here to expand the project. Adjust the sensor’s sensitivity or add an on/off switch to control the system. Endless possibilities. Have fun experimenting!

Arduino Motion Detection Fun for Beginners
Starting motion detecting projects with Arduino boards is fun. Beginner-friendly, open-source, and customisable. Start with these basic motion sensor projects.

PIR sensor alarm

PIR sensors detect room motion. Plug one into your Arduino and set it to alarm when it detects movement. This DIY security system is easy.

Motion-Activated Light

PIR sensors can turn on lights when someone enters a room. Connect the PIR sensor to your Arduino and program it to operate a relay to turn on a bulb or string of lights when motion is detected. Saving energy and automating your house are simple with this.

Motion-following robot

Attach a PIR sensor to a small robot or vehicle and program it to follow motion for a fun robotics project. A PIR sensor signal tells the robot’s motors to move toward the motion. Arduinos operate motors and receive PIR sensor input. This project integrates robotics, programming, and sensors.

Camera security

Build your own security camera to improve motion detection. Arduino-PIR sensor-video camera connection. Set the Arduino to record video when the PIR sensor detects motion. Save or upload the footage to SD or the cloud. This DIY security camera is more complicated but lets you tweak features. You can livestream the footage to your phone or computer.

Arduino motion-activated creations are limitless. Start with an alarm or automatic light, then build a robot or security camera. Arduino projects teach electronics, programming, and mechatronics.


You can create a motion detector in no time with an Arduino, PIR sensor, and other simple components. With help, beginners may complete this job, despite its initial intimidation. Each stage should be tested, and don’t be afraid to be creative with applications. You might inspire a lifelong interest in electronics and coding. Explore Arduino’s universe. Grab your stuff, roll up your sleeves, and tinker—your next big build awaits.

Be the first to comment

Leave a Reply

Your email address will not be published.