element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products & Partners
    Products & Partners
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino Projects
  • Products & Partners
  • Arduino
  • Arduino Projects
  • More
  • Cancel
Arduino Projects
Blog 4WD SLAM Radar 2D Robot Car
  • Blog
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • More
  • Cancel
  • New
Join Arduino Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: lucaeffe03
  • Date Created: 28 Oct 2026 10:55 AM Date Created
  • Views 137 views
  • Likes 7 likes
  • Comments 1 comment
Related
Recommended

4WD SLAM Radar 2D Robot Car

lucaeffe03
lucaeffe03
28 Oct 2026

An autonomous 4-wheel drive explorer robot based on Arduino UNO R4 WiFi, designed to navigate through paths and mazes while detecting surrounding obstacles. The robot performs 180° radar scans via an ultrasonic sensor mounted on a servo motor and transmits real-time telemetry via Wi-Fi (Simultaneous Localization and Mapping) to an interactive Web dashboard, which reconstructs the 2D vector map of the surrounding walls.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Devices & Components

1image

Arduino® UNO R4 WiFi

4image

Geared Motor

3image

IR-Sensors

1image

4WD chassis

1image

2 x 18650 Battery Holder With DC Jack

1image

4 x AA Battery Holder with Jumper Header Wires

1image

Driver L298N

1image

Sensor Shield V5.0

1image

4-channel infrared module

1image

Servo SG90

1image

HC SR04

Wiring and Hardware (3D Model -> 3D_Viewer)

Microcontroller : Arduino UNO R4 WiFi + Sensor Shield V5.0

Chassis & Motors: 4WD Chassis with 4 DC TT gear motors (yellow)

Motor Driver: H-Bridge module L298N (with jumpers inserted on `ENA` and `ENB` to deliver 100% power)

Radar Turret: HC-SR04 ultrasonic sensor mounted on an SG90 micro-servo motor

Waypoint Odometry: Module with 3 Infrared (IR) Sensors positioned under the chassis for detecting configurable checkpoints (black tape at fixed intervals on the floor)

Separate Dual Power Supply:

Logic (Arduino, Wi-Fi, Sensors, Servo): Battery pack with 2 Li-Ion 18650 cells (7.4V – 8.4V) connected to the Arduino R4 Barrel Jack.

Power (4 DC Motors): 4x AA battery holder connected to the 12V/VMS and GND terminals of the L298N driver (with shared `GND` reference with the Sensor Shield and the `+5V` line disconnected to isolate the two circuits).

Pin Map on Sensor Shield

| Component | Module Pin | Arduino Pin (Sensor Shield) | Function |

| L298N Driver | `IN1` | Pin 4 | Left Motor Direction 1 |

| L298N Driver | `IN2` | Pin 12 | Left Motor Direction 2 |

| L298N Driver | `IN3` | Pin 13 | Right Motor Direction 1 |

| L298N Driver| `IN4` | Pin 6 | Right Motor Direction 2 |

| L298N Driver | `ENA` / `ENB` | *Black Jumpers* | Permanent 100% power enable |

| SG90 Servo | VCC/GND/Signal | Column 7 | Radar turret rotation (`5°` – `175°`) |

| HC-SR04 | `TRIG` | Pin 8 | Ultrasonic trigger pulse |

| HC-SR04 | `ECHO` | Pin 9 | Ultrasonic echo return reading |

| IR Sensors | `IR_SX` (`IN1`) | Pin 2 | Left IR Sensor (black tape reading) |

| IR Sensors | `IR_CENTRO` (`IN3`) | Pin 10 | Center IR Sensor (black tape reading) |

| IR Sensors | `IR_DX` (`IN4`) | Pin 11 | Right IR Sensor (black tape reading) |

image

image

Instructions for Use

Uploading the Arduino Sketch

1 - Open the `4wd.ino` file in the Arduino IDE.

2 - Enter your Wi-Fi network name (`ssid`) and password (`password`) in the first lines of the code.

3 - Connect the Arduino R4 WiFi to your computer via USB-C cable and upload the sketch to the board.

Obtaining the IP Address from the Serial Monitor

1 - Once the upload is complete, open the Arduino IDE **Serial Monitor** and set the baud rate to **`115200 baud`**.

2 - Wait a few seconds until the Arduino connects to the Wi-Fi router.

3 - Copy the **local IP address** printed on the screen in the monitor.

4 - Disconnect the USB cable and turn on the batteries (18650 pack on Arduino + 4xAA pack on motors).

Opening the HTML Web Interface

1 - Open the `map.html` file directly in your PC/Mac browser.

(Note for Safari users on Mac: from the top menu `Develop`, enable "Disable Local File Restrictions" to allow the local page to communicate via HTTP with the robot's IP, or use Google Chrome).

2 - In the top-left bar of the web page, paste the robot's **IP address** into the text box and click **"Connect Wi-Fi"**.

image

 

Starting and Stopping Exploration

* Click the light blue **`Arrow forward Start`** button in the top bar to command the robot to begin scanning and autonomous path exploration. 

* Click the red **`Stop button STOP`** button to instantly interrupt motor movement and pause the robot. 

Operating Cycle

Navigation and Mapping Logic

The robot's operating cycle consists of 4 synchronized phases:

1 - **7-Angle Radar Scan:**

While stationary, the robot rotates the SG90 servo motor across 7 angles distributed along the entire front arc (`5°`, `35°`, `65°`, `90°`, `115°`, `145°`, `175°`). At each step, it measures the distance in centimeters using the ultrasonic sensor.

2 - **Free Navigation with Ultrasonic Emergency Brake**

The robot moves using short timed bursts in free space. During travel, ultra-fast monitoring continuously queries the HC-SR04: if a wall drops below 13 cm, the robot brakes instantly to avoid collisions.

3 - **Anti-Double-Scan Disengagement Maneuver:**

If a close front obstacle is detected, the robot reverses by `4.5 cm` (subtracting the displacement from odometry coordinates), inspects the two extremes (`5°` far right and `175°` far left), and rotates toward the freer side. To avoid redrawing the same wall twice by overlapping lines, the software inhibits sending new scans until the robot has completed a new effective forward step.

4 - **Final Target Detection**

The IR sensors passively monitor the floor. As soon as they intercept the single end-of-course black tape, the robot stops the motors, notifies completion, and transmits the target signal to the dashboard.

**Automatic Trajectory Cleaning (In-browser Ray Casting):**

The web dashboard tracks the robot's trail and automatically removes all impact points recorded within a 9 cm radius of the passage, ensuring a central space perfectly clear of phantom points or spurious artifacts, cleanly and continuously highlighting only the outer perimeter walls of the route.

`MAP` Packet Format

The web dashboard cyclically queries the HTTP endpoint `http://<ROBOT_IP>/map` (equipped with CORS header `Access-Control-Allow-Origin: *`). The robot responds with a formatted string:

counter#MAP:posX,posY,thetaAngle|ang1:dist1|ang2:dist2|ang3:dist3|ang4:dist4|ang5:dist5|ang6:dist6|ang7:dist7

Example: 1#MAP:0.0,15.0,90.0|5:14|35:20|65:44|90:57|115:37|145:17|175:160.0, 15.0, 90.0:

The robot is located at X = 0.0 cm, Y = 15.0 cm and heading 90°.5:14... 90:57... 175:16: At various servo angles (from right to left), the sonar detected side walls at 14 cm and 16 cm and the free corridor ahead at 57 cm.

The HTML interface converts each (servoAngle, distance) pair into global Cartesian coordinates using trigonometry (cos⁡cosand sin⁡sin), drawing green impact points and connecting them with cyan vector segments.

CODE--> 4WD-SLAM-Radar-2D-Robot-Car

  • Sign in to reply
  • DAB
    DAB 25 days ago

    Very nice project.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube