How to build a simple smart robot at home.

This article provides detailed instructions on how to assemble and program a simple robot at home using basic components and Arduino, suitable for beginners and helping them learn more about electronics and programming through practical experience.

Lee-Tiptory
Kim Lee Nội dung được xác thực bởi chuyên gia
Cách chế tạo robot thông minh đơn giản tại nhà-Tiptory

Are you passionate about technology and want to build your own smart robot? Don't worry, you don't need to be a professional engineer or programmer to get started! This article will guide you on how to create a simple robot that can move from point A to point B, with options ranging from basic components to ready-made kits. This is not only a fun experience but also helps you learn more about electronics and programming in an easy-to-understand way at home.

Part 1: How to assemble a robot at home: Detailed step-by-step instructions for beginners

Step 1: How to make a simple robot at home for beginners

You don't need to solder the circuits, and most components can be purchased at electronics stores or online. Some kits even include all the necessary components.

Components you need to prepare:

  1. Arduino Uno control board (or equivalent)
    → This is the robot's "brain," controlling all its operations.

  2. 2 servo motors rotate continuously.
    → Helps the robot move forward, backward, or turn.

  3. 2 wheels compatible with servo motors

  4. 1 small auxiliary wheel (caster roller)
    → Helps the robot maintain balance while moving.

  5. 1 test circuit board (breadboard) that doesn't require soldering
    → You should choose a type with two rows of positive and negative power sources on each side.

  6. 1 proximity sensor (with 4-pin connector)
    → Helps the robot detect obstacles ahead.

  7. 1 mini push button
    → Used to start or stop the robot.

  8. 1 resistor 10kΩ
    → Supports stable button connection and operation.

  9. 1 USB A to B cable
    → Used for programming Arduino from a computer.

  10. 1 set of connectors (breakaway headers)
    → Makes it easier to connect components to the breadboard.

  11. 1 box of 6 AA batteries (with 9V DC power jack)
    → Provides power for the robot to operate.

  12. 22 AWG thin plug or wire
    → Used to connect components together.

  13. Hot glue or strong double-sided tape
    → Used to secure parts on the robot's body.

Step 2: Begin assembly: Use the battery box as the robot's body.

Flip the battery box upside down so the back is facing upwards. This will be the base on which you attach the other parts — your robot's "body".

Step 3: Attach the motors: Align them correctly so the robot runs straight.

  • Place the two servo motors at the top of the battery box—where the wires come out.

  • Place the bottom surfaces of the two motors together , parallel to each other on either side of the battery box.

  • The rotating shaft of each motor must be facing outwards.

  • The motor's wiring should be oriented towards the rear, in the same direction as the battery box wiring.

Note: The motors must be aligned perfectly straight and evenly; otherwise, the robot will be unbalanced when moving.

Step 4: Secure the motor: Attach it firmly to ensure the robot is stable.

  • Use strong double-sided tape or hot glue to attach the two servo motors to the battery box.

  • Mount it so that the back of the motor is aligned with the back of the battery box .

  • Make sure the motor is securely attached and not loose.

Result: The two motors will occupy the rear half of the battery box , forming the tail section of the robot's body.

Step 5: Attach the test circuit board (breadboard): Ensure correct position and orientation.

  • Place the breadboard perpendicular to the length of the battery box, in the empty space at the front (the other half).

  • The breadboard should protrude slightly from the front of the battery box and extend a little to the sides .

  • Securely fasten with double-sided tape or hot glue to prevent it from peeling off when plugging in the wires.

  • Ensure that row “A” on the breadboard is facing the servo motor (i.e., facing the back of the robot).

Proper alignment makes it easier to connect wires and components later.

Step 6: Attach the Arduino board: Place it in the correct position for easy connection.

  • Attach the Arduino board onto the two servo motors — the point where they meet will form a small flat surface.

  • Adjust it so that:

    • The USB port and power supply of the Arduino are oriented towards the back of the robot (in the same direction as the battery box and servo wires).

    • The front of the Arduino only slightly overlaps the top of the breadboard.

Tip: Securely attach the circuit board so the robot doesn't move when plugging in wires or programming.

Step 7: Attach the wheels: Press firmly to ensure a secure grip.

  • Take the two wheels and press them firmly onto the servo motor shafts on either side of the robot.

  • A considerable amount of force may be required because the wheels are designed to fit together very tightly to help the robot move steadily and prevent it from slipping .

Note: Ensure the wheels are properly aligned and not loose , otherwise the robot will veer off course or become unbalanced.

Step 8: Attach the auxiliary wheels (casters): These help the robot maintain balance and rotate flexibly.

  • Flip the robot over , and you'll see the breadboard protruding from the front of the battery compartment.

  • Attach the caster wheel to the underside of this protruding breadboard section — this will be the robot's front wheel .

  • If the caster wheels don't reach the ground , use additional risers to adjust the height.

Tip:

  • Some kits include risers that come with a caster.

  • Ensure the caster is securely and straightly mounted so the robot can rotate smoothly while moving.

Part 2: How to wire a home robot: Simple and easy-to-understand component connections

Step 1: Prepare the connectors (headers) for connecting the motor.

  • Break off two sections of 3-pin connectors from the large connector strip.

  • Push the metal pins down so that each pin protrudes equally on both sides of the plastic.
    → The purpose is so you can plug one end into the breadboard , and the other end will connect to the wire from the servo motor .

Note: This is a preparatory step to ensure a quick and neat connection between the motor and the control circuit.

Step 2: Plug the connector into the breadboard: This is the correct location to connect the motor.

  • Plug the two 3-pin headers into row E of the breadboard:

    • The first section goes into holes 1 to 3.

    • The second section goes into holes 6 to 8.

  • Make sure the pins are securely and vertically plugged in , not loose.

Purpose: This will serve as an intermediate point to easily and conveniently connect the servo motor wires to the control circuit .

Step 3: Connect the wires from the servo motor to the breadboard.

  • Connect the servo motor wires to the connectors (headers) that have just been attached to the breadboard:

    • The black wire (GND wire) of each servo is on the left , meaning it plugs into pins 1 and 6 .

    • The left servo is connected to the left header (pins 1–3).

    • The right servo is connected to the right header (pins 6–8).

Note:

  • Connect the wires in the correct color order (black – red – yellow) to avoid short circuits.

  • Make sure you don't connect the left and right servos incorrectly so the robot operates correctly.

Step 4: Power the motor: Connect the power wire to the positive rail.

  • Use the two red jumper wires to connect:

    • Pin C2 → to the red (positive) rail at the back of the breadboard

    • Pin C7 → is also connected to this same red rail.

Note:

  • This red rail is the common positive power supply for the components.

  • Use the rail behind the breadboard (closer to the robot's body) to keep the wires tidy and easy to manage.

Step 5: Connect the ground wire (GND): Connect the motor to ground.

  • Use two black jumper wires to connect:

    • Pin B1 → into the green rail (GND) behind the breadboard

    • Pin B6 → also connects to this same green rail.

Important note:

  • Only plug into the green (ground) raildo not plug into the red (positive) rail , otherwise it will cause a short circuit.

  • The green rail at the back will provide a common ground connection for the entire robot system.

Step 6: Connect the control wires from the Arduino to the motor.

  • Use two white jumper wires to connect:

    • Pin 12 on Arduino → to hole A3 on the breadboard

    • Pin 13 on Arduino → to hole A8 on the breadboard

Meaning:

  • These are the control signal wires from the Arduino to the two servo motors.

  • Use Arduino to command the wheels to spin , guiding the robot to move as desired.

Step 7: Attach the proximity sensor: Center position, do not use external rails.

  • Plug the proximity sensor into row J (the row with the letter) on the breadboard, right in front of the robot .

  • Position the sensor so that it is centered , with an equal number of holes on both sides .

  • Do not plug the sensor into the external rails (power/ground wires) of the breadboard.

Note:

  • Proper placement ensures the sensor works effectively and the wires don't get tangled.

  • This sensor will help the robot detect obstacles ahead to avoid collisions.

Step 8: Connect the sensor to ground: Ensure stable operation.

  • Use a black jumper wire to connect:

    • Pin I14 (right after the sensor pin) → to the green (ground) rail to the left of the sensor (behind the breadboard).

Purpose:

  • This connection helps to ground (GND) the distance sensor, which is necessary for the sensor to operate stably and accurately.

  • Make sure you plug it into the blue rail , avoiding confusion with the red rail (positive power).

Step 9: Power the sensor: Connect it to the male rail.

  • Use a red jumper wire to connect:

    • Pin I17 (sensor power supply pin) → to the red rail (positive power) to the right of the sensor (behind the breadboard).

Purpose:

  • Provide the operating voltage (VCC) to the distance sensor.

  • Make sure the wires are plugged correctly into the red rail , not the ground (green rail).

Step 10: Connect the sensor signal to the Arduino: Transmit control data.

  • Use the two white jumper wires to connect:

    • Pin I15 (the first signal pin of the sensor) → to pin 9 on the Arduino.

    • Pin I16 (second signal pin) → to pin 8 on Arduino

Purpose:

  • Allows the sensor to send distance data to the Arduino.

  • From there, Arduino will process the information and control the robot to avoid obstacles.

Part 3: How to Power Your DIY Robot: Safe and Effective at Home

Step 1: How to position the robot so the battery is visible.

  • Lay the robot on its side.

  • Rotate the robot so you can clearly see the battery compartment.

  • Make sure the battery box cable is at the bottom, pulling out to the left.

Step 2: Connect the red wire to the correct position on the battery box.

  • Connect a red wire to the second spring from the left at the bottom.

  • Double-check to ensure the battery pack is facing the correct direction.

Step 3: Connect the black wire to power the Arduino.

  • Connect the black wire to the last spring in the bottom right corner.

  • These two wires will help provide the correct voltage to the Arduino.

Step 4: Connect the wires to the pins on the circuit board.

  • Connect the red and black wires to the red and blue pins on the right side of the circuit board.

  • The black wire plugs into the green pin at position 30.

  • The red wire is plugged into the red pin at position 30.

Step 5: Connect the GND wire from the Arduino to the circuit board.

  • Connect the black wire from the GND pin on the Arduino to the green strip on the back of the circuit board.

  • Plug the wire into pin 28 on the green bar.

Step 6: Connect the black wires between the green strips on the circuit board.

  • Connect the black wire from the rear green bar to the front green bar at pin 29.

  • Do not connect to the red bars to avoid damaging the Arduino.

Step 7: Power the Arduino using the red wire.

  • Connect the red wire from the front red bar at pin 30 to the 5V pin on the Arduino.

  • This wire will supply power to the Arduino.

Step 8: Install a switch to easily turn the robot off.

  • Plug the switch into the slot between pins 24-26.

  • This switch allows you to turn off the robot without having to unplug it from the power source.

Step 9: Power on the switch

  • Connect the red wire from pin H24 to the red bar on the next pin to the right of the sensor.

  • This wire will power the switch.

Step 10: Connect the resistor to the circuit board.

  • Use a resistor to connect H26 to the green bar.

  • Plug the resistor into the pin right next to the black wire that you connected earlier.

Step 11: Connect the white wire so that the Arduino recognizes the switch.

  • Connect the white wire from G26 to pin 2 on the Arduino.

  • This wire helps the Arduino recognize the switch.

Part 4: Instructions for installing Arduino software to program robots at home.

Step 1: Download and use the Arduino IDE

  • Download and extract the Arduino IDE from arduino.cc/en/main/software. This is the development environment for programming and uploading code to the Arduino microcontroller.

  • After downloading, double-click the file to extract it, then move the folder to an easily accessible location.

  • You don't need to install the program; just run it directly from the extracted folder by double-clicking the arduino.exe file.

Step 2: Connect the power supply to the Arduino.

  • Connect the battery pack to the Arduino.

  • Plug the battery box's jack into the connector port on the Arduino to power it.

Step 3: Connect the Arduino to the computer.

  • Connect the Arduino to your computer via the USB port.

  • Windows may not recognize the device immediately.

Step 4: Open Device Manager on Windows

  • Press the Win+R key combination, then type devmgmt.msc .

  • This command will open Device Manager.

Step 5: Update the device's driver software.

  • Right-click on "Unknown device" in the "Other devices" section and select "Update Driver Software."

  • If you don't see this option, click "Properties," select the "Driver" tab, and then click "Update Driver."

Step 6: Select the driver for Arduino

  • Select "Browse my computer for driver software."

  • This allows you to select the driver included with the Arduino IDE.

Step 7: Select the driver folder

  • Press "Browse" and then navigate to the folder you extracted earlier.

  • There will be a folder called "drivers" inside.

Step 8: Confirm driver installation

  • Select the "drivers" folder and click "OK."

  • Confirm to continue if you receive a warning about software from an unknown source.

Part 5: How to program a robot to move using Arduino: Easy-to-apply sample code

Step 1: Open the Arduino IDE

  • Open the Arduino IDE by double-clicking the arduino.exe file in the IDE folder.

  • You will see an empty project when you open the program.

Step 2: Paste the code to make the robot move straight.

  • Paste the code below into the Arduino IDE to make the robot move straight. This code allows the Arduino to continuously move forward.

 #include <Servo.h> // thêm thư viện "Servo" vào chương trình
 
// create two servo objects
 Servo left motor;
 Servo rightMotor;

 Void setup()
 {
 leftMotor.attach(12); // If you accidentally change the connection pins, you can change the pin numbers here.
 rightMotor.attach(13);
 }

 Void loop()
 {
 leftMotor.write(180); // With continuous rotation, 180 causes the servo to move at maximum speed "forward"
 rightMotor.write(0); // If both are at 180, the robot will turn around because the servos are reversed. "0" will move at maximum speed "backward."
 } 

Step 3: Download and run the program on Arduino

  • Build and upload the program to Arduino. Press the right arrow button in the upper left corner to build and upload the program to the connected Arduino.

  • You might want to lift the robot off the ground, as it will continue moving forward once the program is loaded.

Step 4: Add a kill switch function.

  • Add the following code to the void loop() section of your program to activate the toggle switch. Place this code above the write() statements.

 if(digitalRead(2) == HIGH) // kiểm tra khi nút nhấn trên chân 2 của Arduino được nhấn
 {
 while(1)
 {
 leftMotor.write(90); // "90" là vị trí trung tính cho servo, khiến nó ngừng quay
 rightMotor.write(90);
 }
 }
  • This will help the robot stop immediately when the button is pressed.

Step 5: Download and test the code with the power switch off.

  • Download and test your code. With the added off switch function, the robot will continue moving forward until you press the switch, at which point it will stop.

 #include <Servo.h>

 // tạo hai đối tượng servo
 Servo leftMotor; 
Servo rightMotor;

 Void setup()
 {
 leftMotor.attach(12);
 rightMotor.attach(13);
 }

 Void loop()
 {
 if(digitalRead(2) == HIGH)
 {
 while(1)
 {
 leftMotor.write(90);
 rightMotor.write(90);
 }
 }

 leftMotor.write(180);
 rightMotor.write(0);
 }
  • After uploading the code to the Arduino, the robot will continue moving until the off switch is pressed, causing the robot to stop.

Part 6: Controlling a robot to avoid obstacles using sensors

Below is the complete code for your robot, which allows it to move forward and turn left when encountering obstacles using ultrasonic sensors.

 #include <Servo.h>

 Servo left motor;
 Servo rightMotor;

 const int serialPeriod = 250; // Limit console output every 1/4 second
 unsigned long timeSerialDelay = 0;

 const int loopPeriod = 20; // Sensor reads data every 20ms (frequency 50Hz)
 unsigned long timeLoopDelay = 0;
 
// Assign TRIG and ECHO pins to the ultrasonic sensor
 const int ultrasonic2TrigPin = 8;
 const int ultrasonic2EchoPin = 9;

 int ultrasonic2Distance;
 int ultrasonic2Duration;

 // Define two states: going straight or turning left
 #define DRIVE_FORWARD 0
 #define TURN_LEFT 1

 int state = DRIVE_FORWARD; // 0 = go straight (DEFAULT), 1 = turn left

 Void setup()
 {
 Serial.begin(9600);

 pinMode(ultrasonic2TrigPin, OUTPUT);
 pinMode(ultrasonic2EchoPin, INPUT);

 leftMotor.attach(12);
 rightMotor.attach(13);
 }

 Void loop()
 {
 if(digitalRead(2) == HIGH) // Check the off switch
 {
 while(1)
 {
 leftMotor.write(90);
 rightMotor.write(90);
 }
 }

 debugOutput(); // Prints debug message to console

 if(millis() - timeLoopDelay >= loopPeriod)
 {
 readUltrasonicSensors(); // Read and save the sensor distance

 stateMachine(); // Handles the robot's state

 timeLoopDelay = millis(); 
}
 }

 Void stateMachine()
 {
 if(state == DRIVE_FORWARD) // If there is no obstacle
 {
 if(ultrasonic2Distance > 6 || ultrasonic2Distance < 0) // If there is no obstruction in front
 {
 rightMotor.write(180); // Move straight
 leftMotor.write(0);
 }
 else // If there is an obstacle
 {
 state = TURN_LEFT; // Switch to left-rotated state
 }
 }
 else if(state == TURN_LEFT) // If there is an obstacle, turn left
 {
 unsigned long timeToTurnLeft = 500; // Time to rotate 90 degrees (~0.5 seconds)
 unsigned long turnStartTime = millis(); // Save the start time of the turn

 while((millis() - turnStartTime) < timeToTurnLeft) // Rotate for a specified period of time
 {
 rightMotor.write(180);
 leftMotor.write(180);
 }

 state = DRIVE_FORWARD; // After turning, return to straight-ahead state
 }
 }

 void readUltrasonicSensors()
 { 
digitalWrite(ultrasonic2TrigPin, HIGH);
 delayMicroseconds(10); // Keep TRIG pin high for at least 10 microseconds
 digitalWrite(ultrasonic2TrigPin, LOW);

 ultrasonic2Duration = pulseIn(ultrasonic2EchoPin, HIGH);
 ultrasonic2Distance = (ultrasonic2Duration / 2) / 29; // Calculates the distance from the pulse length
 }

 // Output for debugging on the console
 Void debugOutput()
 {
 if((millis() - timeSerialDelay) > serialPeriod)
 {
 Serial.print("ultrasonic2Distance: ");
 Serial.print(ultrasonic2Distance);
 Serial.print("cm");
 Serial.println();

 timeSerialDelay = millis();
 }
 }

Explain:

  1. Ultrasonic sensors : Measure distance and help the robot detect obstacles.

  2. Robot movement : The robot moves straight when there are no obstacles, and turns left when it encounters an obstacle.

  3. Kill Switch : When the button is pressed, the robot stops.

Download and test the code on Arduino so the robot can automatically avoid obstacles and turn left when encountering them.

Translated by: Rowan Hudson Le .

Lee-Tiptory
Kim Lee Founder of Tiptory

Tiptory is a global knowledge-sharing platform that helps people learn how to do things through practical experiences contributed and shared freely by the community.

Updated on Ngày 16 tháng 07 năm 2026 (GMT +7)

3 comments

Hãy nhớ đo từng bộ phận trước khi mua để bạn không phải trả lại bất cứ thứ gì!

Lê Thanh HảiJul 13, 2025

Nếu bạn muốn thêm cá tính cho robot của mình, hãy cắt mắt, tay và chân ra khỏi giấy, sau đó dán chúng bằng băng dính.

Hùng NguyễnJul 12, 2025

Gắn 2 đầu bàn chải đánh răng vào đế robot nếu bạn muốn nó quét sàn.

Quang Linh PhạmJul 11, 2025

Leave a comment

Please note, comments need to be approved before they are published.

Practical knowledge

Expert Q&A

In-depth analysis and practical advice from leading experts.

Absolutely! This article is for beginners only; you don't need to be an engineer or programmer. You just need to know how to wire and assemble the parts like Lego. There are robot kits that make things even easier – just follow the instructions and the robot will be running!

You can easily buy them online or at electronics stores! Items like Arduino boards, servo motors, and proximity sensors are widely available on sites like Shopee, Lazada, or at local electronics shops. A little tip: choose complete kits to save time and effort searching for individual components!

Don't worry, nothing is "broken"! DIY robots are easy to fix – usually it's just a matter of miswired connections or loose connections. You can check each step in the instructions to make adjustments. And if it still doesn't work, don't hesitate to ask the community or Arduino forums – there's always someone willing to help.

Commitment to providing truthful information

Disclaimer

The content on Tiptory is for informational purposes only, based on expertise and practical experience. We are not responsible for any risks arising from the application of this information. Readers are responsible for their own judgment and decisions.
Ashley_Wright_Nguyen-Tiptory
Rene_Lee_Nguyen-Tiptory
Sidney_Bailey_Hoang-Tiptory
Leigh_Kennedy_Ly-Tiptory
Rowan_Hudson_Le-Tiptory
Tiptory_Banner_3-Tiptory