Arduino & Robotics Tutorials
Learn by building. Follow simple, step-by-step tutorials and bring your ideas to life.
All Projects
Arduino Traffic Light
Build a working traffic light system and learn how Arduino controls multiple digital outputs with timing.
Arduino Ultrasonic Distance Meter
Measure distance with an HC-SR04 ultrasonic sensor and display the result on an LCD.
Arduino Keypad Door Lock
Build a password-controlled lock using a 4×4 keypad and SG90 servo motor.
Arduino Obstacle Avoiding Robot
Build a robot that detects obstacles using an ultrasonic sensor and controls its motors through an L298 driver.
Bluetooth Controlled Car
Control a 4-wheel robot car from a phone using the HC-05 Bluetooth module.
Automatic Plant Watering System
Use a capacitive soil moisture sensor to detect dry soil and automatically activate a small water pump.
Arduino Automatic Dustbin
Build a touchless dustbin that opens its lid when your hand approaches.
Joystick Controlled Servo
Control the position of an SG90 servo motor using the X-axis of an Arduino joystick module.
Motion Activated Light
Use a PIR motion sensor and relay module to automatically switch a low-voltage load on when movement is detected.
Ready to start building?
Get the individual components you need for your next project from Robo.pk.
Arduino Traffic Light
Project Overview
In this project, you'll build a simple traffic light using an Arduino and a traffic light module. The Arduino will turn the red, yellow and green LEDs on and off in sequence.
What You'll Need
- Arduino UNO R3
- 5V LED Traffic Light Module
- 400-hole breadboard
- Jumper wires
How It Works
Each LED on the traffic light module is connected to a digital output.
Arduino activates one light at a time using digitalWrite()
and waits between each change using delay().
Wiring
| Traffic Light | Arduino |
|---|---|
| Red | D8 |
| Yellow | D9 |
| Green | D10 |
| GND | GND |
Arduino Code
Step-by-Step
- Connect the traffic light module to the Arduino.
- Connect the module ground to Arduino GND.
- Upload the code.
- The red light should turn on first.
- The green light will then turn on.
- Finally, the yellow light will turn on before the cycle repeats.
Testing
If the lights change in the correct sequence, your project is working. You can experiment with the delay times to create a faster or slower traffic-light cycle.
Troubleshooting
- Check that GND is connected correctly.
- Make sure the LED control wires are connected to the correct pins.
- Verify that the code uploaded successfully.
🛒 Shop the Components
Arduino Ultrasonic Distance Meter
Project Overview
Build a simple distance meter using an HC-SR04 ultrasonic sensor. The measured distance will be displayed on an I2C LCD.
What You'll Need
- Arduino UNO R3
- HC-SR04 Ultrasonic Sensor
- 16×2 LCD with I2C
- 400-hole breadboard
- Jumper wires
How It Works
The HC-SR04 sends an ultrasonic pulse and measures how long it takes for the echo to return. Arduino converts this time into distance.
Wiring
| HC-SR04 | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| TRIG | D9 |
| ECHO | D10 |
| LCD I2C | Arduino UNO |
|---|---|
| VCC | 5V |
| GND | GND |
| SDA | A4 |
| SCL | A5 |
Arduino Code
Step-by-Step
- Connect the HC-SR04 to the Arduino.
- Connect the LCD through its I2C pins.
- Install the LiquidCrystal_I2C library.
- Upload the code.
- Place an object in front of the ultrasonic sensor.
- The LCD should display the approximate distance.
Troubleshooting
- If the LCD is blank, adjust the small contrast potentiometer on the I2C module.
- If the LCD doesn't respond, check the I2C address. Some modules use 0x3F instead of 0x27.
- Check TRIG and ECHO connections carefully.
🛒 Shop the Components
Arduino Keypad Door Lock
Project Overview
Build a simple electronic lock using a 4×4 matrix keypad and an SG90 servo motor. The servo unlocks when the correct password is entered.
What You'll Need
- Arduino UNO R3
- 4×4 Matrix Keypad
- SG90 Servo Motor
- Jumper wires
Wiring
| Component | Arduino |
|---|---|
| Keypad Row 1–4 | D2–D5 |
| Keypad Column 1–4 | D6–D9 |
| Servo Signal | D10 |
| Servo VCC | 5V |
| Servo GND | GND |
Arduino Code
Step-by-Step
- Connect the keypad rows and columns.
- Connect the SG90 servo signal wire to D10.
- Install the Keypad library.
- Upload the code.
- Enter 1234 followed by #.
- The servo should move to the unlocked position.
Testing
Try entering an incorrect password. The servo should remain locked. Then enter 1234 followed by # and check that the servo moves.
Troubleshooting
- Check the keypad row and column order.
- Make sure the servo has a common ground with Arduino.
- Check that the Keypad library is installed.
🛒 Shop the Components
Arduino Obstacle Avoiding Robot
Project Overview
Build a robot that drives forward and automatically changes direction when it detects an obstacle in front of it.
What You'll Need
- Arduino UNO R3
- HC-SR04 Ultrasonic Sensor
- L298 Motor Driver
- 4-Wheel Robot Car Chassis
How It Works
The ultrasonic sensor continuously measures the distance in front of the robot. When the robot gets too close to an obstacle, Arduino tells the motor driver to change the robot's movement.
Basic Wiring
| Component | Arduino |
|---|---|
| HC-SR04 TRIG | D2 |
| HC-SR04 ECHO | D3 |
| L298 IN1 | D5 |
| L298 IN2 | D6 |
| L298 IN3 | D9 |
| L298 IN4 | D10 |
Arduino Code
Step-by-Step
- Assemble the 4-wheel chassis.
- Connect the motors to the L298 driver.
- Connect the L298 control pins to Arduino.
- Mount the HC-SR04 at the front of the robot.
- Upload the code.
- Place the robot on the floor.
- Place an object in front of it and watch the robot turn away.
Troubleshooting
- If the robot moves backward, swap the motor polarity.
- If only one side moves, check the motor-driver connections.
- If the robot doesn't detect obstacles, check TRIG and ECHO.
- Make sure the motor supply is adequate.
🛒 Shop the Components
Bluetooth Controlled Car
Project Overview
Control a 4-wheel robot car wirelessly from a smartphone using an HC-05 Bluetooth module.
What You'll Need
Bluetooth Wiring
- HC-05 VCC → Arduino 5V
- HC-05 GND → Arduino GND
- HC-05 TXD → Arduino D10
- Arduino D11 → HC-05 RXD through a voltage divider
The HC-05 communicates with the Arduino using serial communication. In this setup, D10 is used as the Arduino's SoftwareSerial RX pin and D11 as the SoftwareSerial TX pin. Because the HC-05 RX pin is a 3.3V logic input, use a voltage divider between Arduino D11 and HC-05 RXD.
How It Works
The phone sends simple commands over Bluetooth. Arduino receives the characters and uses them to control the L298 motor driver.
Example Commands
- F = Forward
- B = Backward
- L = Left
- R = Right
- S = Stop
Arduino Code
Step-by-Step
- Build the 4-wheel chassis.
- Connect the motors to the L298 driver.
- Connect the L298 control pins to Arduino.
- Connect the HC-05 module to Arduino as follows:
- HC-05 TX → Arduino D10 (SoftwareSerial RX)
- HC-05 RX → Arduino D11 (SoftwareSerial TX) through an appropriate voltage divider or level-shifting arrangement
- HC-05 VCC → appropriate supply for your HC-05 module
- HC-05 GND → Arduino GND
- Pair your phone with the HC-05.
- Use a Bluetooth terminal/controller app to send commands.
- Test forward, backward, left, right and stop.
🛒 Shop the Components
Automatic Plant Watering System
Project Overview
Build a simple automatic plant watering system. Arduino checks the soil moisture and activates a small water pump when the soil becomes dry.
What You'll Need
- Arduino UNO R3
- Capacitive Soil Moisture Sensor
- 1 Channel Relay
- Mini Submersible Water Pump
How It Works
The moisture sensor provides Arduino with a reading related to soil moisture. When the reading indicates dry soil, Arduino activates the relay, which switches the pump on.
Wiring
| Soil Sensor | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| AOUT | A0 |
| Relay | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| IN | D7 |
For the pump circuit, connect the external pump power supply positive terminal to the relay COM terminal. Connect the relay NO terminal to the pump positive terminal. Connect the pump negative terminal directly to the external power supply negative terminal. Use an external supply suitable for your pump's voltage and current.
Arduino Code
Step-by-Step
- Connect the capacitive moisture sensor to A0.
- Connect the relay input to D7.
- Connect the pump through the relay's switching terminals as described above.
- Connect the pump to a suitable external power supply.
- Upload the code.
- Open Serial Monitor and observe the moisture readings.
- Adjust the dry threshold according to your soil and sensor.
Troubleshooting
- Use Serial Monitor to see your sensor's actual readings.
- The threshold in the example may need adjustment.
- If the relay behaves backwards, check whether your module is active LOW.
- Make sure the pump has its own suitable power source.
🛒 Shop the Components
Arduino Automatic Dustbin
Project Overview
Build a touchless dustbin that automatically opens when an object approaches the ultrasonic sensor.
What You'll Need
- Arduino UNO R3
- HC-SR04 Ultrasonic Sensor
- SG90 Servo Motor
How It Works
The HC-SR04 measures the distance to your hand. If your hand comes within a set distance, Arduino rotates the servo to open the lid.
Wiring
| Component | Arduino |
|---|---|
| HC-SR04 TRIG | D7 |
| HC-SR04 ECHO | D8 |
| Servo Signal | D9 |
| VCC | 5V |
| GND | GND |
Arduino Code
Step-by-Step
- Mount the servo so it can move the lid.
- Mount the ultrasonic sensor near the top/front of the bin.
- Connect the sensor and servo to Arduino.
- Upload the code.
- Move your hand within approximately 20 cm of the sensor.
- The lid should open and then close automatically.
Troubleshooting
- Adjust the 20 cm detection distance in the code.
- Make sure the servo has a common ground with Arduino.
- If the lid moves in the wrong direction, change the servo angles.
🛒 Shop the Components
Joystick Controlled Servo
Project Overview
Learn how analog input works by using an Arduino joystick to control the angle of an SG90 servo motor.
What You'll Need
- Arduino UNO R3
- PS2 Joystick Module
- SG90 Servo Motor
How It Works
The joystick's X-axis produces an analog value between approximately 0 and 1023. Arduino maps this value to a servo angle between 0 and 180°.
Wiring
| Joystick | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| VRx | A0 |
| Servo | Arduino |
|---|---|
| Signal | D9 |
| VCC | 5V |
| GND | GND |
Arduino Code
Step-by-Step
- Connect the joystick's VRx output to A0.
- Connect the servo signal to D9.
- Connect the grounds together.
- Upload the code.
- Move the joystick left and right.
- The servo should follow the joystick position.
What You'll Learn
- Analog inputs
- Analog-to-digital conversion
- Mapping values
- Servo control
🛒 Shop the Components
Motion Activated Light
Project Overview
Build a simple motion-triggered automation system using a PIR sensor and a relay. When movement is detected, Arduino activates the relay.
What You'll Need
- Arduino UNO R3
- HC-SR501 PIR Motion Sensor
- 1 Channel Relay
- A suitable low-voltage load for testing
How It Works
The PIR sensor outputs a HIGH signal when it detects movement. Arduino reads that signal and switches the relay accordingly.
Wiring
| PIR Sensor | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| OUT | D2 |
| Relay | Arduino |
|---|---|
| VCC | 5V |
| GND | GND |
| IN | D7 |
Arduino Code
Step-by-Step
- Connect the PIR sensor to Arduino.
- Connect the relay input to D7.
- Connect a suitable low-voltage load to the relay.
- Upload the code.
- Allow the PIR sensor a short time to initialize.
- Move in front of the sensor.
- The relay should activate.
Troubleshooting
- PIR sensors can take several seconds to stabilize after power-up.
- Adjust the PIR sensitivity and delay controls if needed.
- If the relay works backwards, your relay module may use active-LOW logic.

