Getting Started

This robot build is meant to be relatively cheap and easy. It should provide a good first project for people looking to learn to code, specifically in the Python programming language. Here is what you will need to get started:



  • Hot Glue Gun
  • Soldering Iron

Prepare Frame

  • Decide how you will position your components.
  • This is important to do before you start installing components.

HC-SR04 Sensor

  • Install the HC-SR04 sensor by press fitting it into the holes in the frame.
  • Position the sensor so that the pins are facing up.
  • Using hot glue, secure the sensor in place.

HCSR04HC-SR04 Installed.


  • To install the motors, slightly lift up on one of the tabs on the frame.
  • Push the motor into the slot under the tab until it reaches the end.
  • The tabs have “teeth” on the end which should clip onto the motor housing, keeping it secure without the need for glue.
MotorsMotors installed
Dual H-Bridge Motor Driver

  • Connect each lead from the motors into the “out” pins on the H-Bridge board
    • Do not worry about which lead connects to each “out” pin. We can change the pins later if necessary.
  • Glue the H-Bridge board onto the frame.
H-Bridge Installed.

Buck Converter & Bread Board

  • Solder the proper leads onto your Buck Converter.
    • The leads connected to the in+ and in- spots should have a connector that is compatible with that of the lipo battery.
    • The leads coming off of the out+ and out- can be normal jumper wires.
    • The out+ will power the motors, connect it to the +12V terminal on the H-bridge.
    • The out- will need to have 2 leads coming off of it.
      • One will be connected to ground on the H-Bridge.
      • The other lead will be connected to a ground pin on the Raspberry Pi. This lead acts as a common ground.
  • The breadboard will be used to create a voltage dividing circuit. This will be covered more in depth in the next step.
TopNoWheelsBuck Converter Installed (Top Left), Breadboard Installed (Top Right).

Wiring the Dual H-Bridge

IN1 -> GPIO 2

IN2 -> GPIO 3

IN3 -> GPIO 4

IN4 -> GPIO 17

Wiring the Ultrasonic Sensor



ECHO -> Voltage Dividing Circuit -> GPIO 22

Voltage Dividing Circuit Guide.

Why use a voltage dividing circuit?

The echo pin on the HC-SR04 sensor outputs 5 volts. The GPIO pins on the Pi are only rated for 3.3 volts. Giving a GPIO pin 5 volts may cause damage to the Pi. A voltage dividing circuit will convert the 5V signal from the HC-SR04 into 3.3V, safe for the Raspberry Pi.

Software Setup

Here is what you need to do to get the necessary software up and running.

  1. Install Raspbian onto a micro SD.
  2. Enable SSH and setup WiFi configuration.
  3. SSH into the Raspberry Pi.
  4. Download the code from GitHub.
  5. Download any missing dependencies.
  6. Bring your robot to life.

1. Installing Raspbian

To burn an image to the SD card you can use Etcher.

  • Head over to
  • Download the version for your operating system.
  • Run the installer.

Screen Shot 2018-10-21 at 7.09.39 PM

Using Etcher is very intuitive and straight forward.

  1. Select image – Browse to the Raspbian image that you downloaded.
  2. Select disk – Select the SD card for your Raspberry Pi.
  3. Click “Flash!” Then wait for the image to be written.
  4. Done! Raspbian is now installed on the SD card.

Screen Shot 2018-10-21 at 7.10.22 PM

2. Enable SSH and configure WiFi

For security reasons, SSH is disabled by default. To enable SSH you will need to keep the Raspberry Pi’s micro SD card inserted into your computer after Raspbian has been copied onto it.

Mac Users

  • Open a terminal and run “touch /Volumes/boot/ssh” to create a file named “ssh” on the SD card.

Windows Users

  • Using Notepad, open a new file, enter one empty space and nothing more
  • Click File / Save As …
  • Be sure to set Save As type to All Files (so the file is not saved with a .txt extension)
  • Name the file ssh and save it onto the SD card.

Configuring the WiFi prior to boot is very useful for a headless Raspberry Pi. Doing so removes the need for an extra keyboard, mouse, monitor, and HDMI cable.

To setup the WiFi configuration file, you will need to:

  1. Create the configuration file on the SD card.
  2. Enter the following text into the configuration file;


ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev






Mac Users

  • Open a terminal and run “touch /Volumes/boot/wpa_supplicant.conf” to create the WiFi configuration file on the SD card.
  • Edit the wpa_supplicant.conf file and paste the text from above into the file. Make sure to enter your WiFi login details in the correct field (NETWORK-NAME).

Windows Users

  • Using Notepad, paste in the text from above. Make sure to enter your WiFi login details in the correct field (NETWORK-NAME).
  • Click File / Save As …
  • Be sure to set Save as type to All Files (so the file is not saved with a .txt extension)
  • Save the file as “wpa_supplicant.conf“.

3. SSH into the Raspberry Pi

  • Eject SD card from your computer and insert it into the Raspberry Pi.
  • Power on the Raspberry Pi and wait for it to boot up (> 90 seconds)
  • Find ip address of the Raspberry Pi

Mac Users

  • Open a terminal and run “ssh pi@ip_address_of_pi” replacing ip_address_of_pi with the actual ip address of your Raspberry Pi.
  • A prompt may appear asking if you would like to continue connecting despite the lack of authenticity. Enter “yes“.
  • Then you will be prompted for the password. The default password is “raspberry“.

Windows Users

  • Head over to and download the version for your operating system.
  • In PuTTY, create a new configuration for your Raspberry Pi.
    • Default username: pi
    • Default password: raspberry
    • Host name: ip address for your Raspberry Pi
    • Port: 22
  • SSH into your Raspberry Pi.

After SSH-ing into your raspberry pi you will want to update the system by running:

  1. sudo apt-get update
  2. sudo apt-get upgrade

You should then improve the security of your Raspberry Pi by following this guide.

Screen Shot 2018-10-21 at 8.37.17 PM.png

4. Download the code from GitHub

While connected to your Raspberry Pi over SSH:

Screen Shot 2018-10-21 at 8.48.14 PM.png

5. Download any missing dependencies

My code relies on the RPi.GPIO library to work correctly.

  • Download RPi.GPIO using pip3 by running “pip3 install RPi.GPIO”

Screen Shot 2018-10-21 at 8.51.27 PM.png

6. Bring your robot to life

  • Change into the ARCRobot-1 directory inside of the arcrobot directory by running “cd arcrobot/ARCRobot-1/”
  • Start the robot’s autonomous mode by running “python3

Screen Shot 2018-10-21 at 8.55.42 PM.png

That’s it! Whenever you reboot your Raspberry Pi, all you need to do is re-do step 6 to get your robot up and running. Thank you for following my guide! Please leave feedback regarding anything that was unclear so that I can help clarify.

One thought on “Build a 3D Printed Autonomous Robot

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s