

Take your drone skills to the next level by building a collision-avoidance system. This project combines IR proximity sensing with flight control commands (pitch), teaching you how to make a drone react to its environment and autonomously avoid obstacles - a fundamental concept in autonomous navigation.
Build a drone that detects nearby objects and automatically moves away to avoid collisions.
The IRSense module contains an IR LED emitter and an IR light receiver. It works by emitting infrared light and detecting its reflection from nearby objects. When no object is present, the sensor outputs HIGH. When an object is detected within range, the output drops to LOW. The detection range can be adjusted using the onboard potentiometer.
Connect the IRSense to the RC port on the Primus V5/X2 board. Point the IR sensor in the forward direction of the drone for front-facing obstacle detection. The detection range is typically 2-30cm and can be adjusted via the onboard potentiometer.
| Primus V5/X2 Pin | Peripheral |
|---|---|
Open this code in PlutoBlocks to program your drone. The visual blocks below show the complete solution.

PlutoBlocks visual code for IRSense project
PlutoIDE C++ code for this module is coming soon. Stay tuned for updates!
Ready for the next challenge? Try these extensions to deepen your understanding.
| VCC on RC port |
| VCC on IR_module |
| GND on RC port | GND on IR_module |
| Signal on RC port | D0 on IR_module |
Approach We read the IR sensor to detect nearby objects. When an obstacle is detected and the timer condition is met, we command the drone to pitch backward for 1 second to move away from the obstacle. Code Logic Explained On Start: A repeating timer (Timer1) is set with a 1000ms interval. This timer controls the duration of the evasion maneuver.Pluto Loop: The code continuously reads GPIO_1 (IR sensor on RC port). Under normal conditions, the IR sensor outputs HIGH (1). When it detects an object nearby, the output goes LOW (0). The code checks two conditions: GPIO_1 equals 0 AND Timer1 is true. When both are satisfied, Set Pitch is set to 1350 (above the neutral 1500 midpoint, causing backward movement) for the timer duration. Otherwise, Pitch follows the RC controller input (RC Pitch), giving the pilot normal control. Yellow LED indicates the developer mode is active.On Stop: Timer1 is reset. Pitch Evasion 1500Neutral Pitch 1000msTimer Duration DigitalSensor Output
Collision avoidance for indoor drone flights Wall-following autonomous drone Obstacle detection in confined spaces
Ready for the next challenge? Try these extensions to deepen your understanding. 1Mount a second IR sensor for channel-following (flying between two walls). 2Build a wall-following drone that maintains constant distance from surfaces. Pluto Drone Add-On Projects — Compatible with Pluto 1.2 (Primus V5) & Pluto X (Primus X2) — Drona Aviation