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:

Hardware

Tools

  • Hot Glue Gun
  • Soldering Iron

Prepare Frame

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

 

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, glue the sensor in place.
HCSR04 Installed

 

Motors

  • 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.
Motors 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 to connect to the lipo battery.
    • The leads coming off of the out+ and out- can be normal jumper wires.
    • 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 convered more in depth in the next step.
Buck Converter (upper left) and Bread Board (upper right) Installed

Wiring the Dual H-Bridge

IN1 -> GPIO 2

IN2 -> GPIO3

IN3 -> GPIO 4

IN4 -> GPIO 17

Wiring the Ultrasonic Sensor

VCC -> 5V GPIO

TRIG -> GPIO 27

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 give 3.3 volts to GPIO 22.

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 https://etcher.io.
  • 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.

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)
  • Save the file as ssh 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;

country=US

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

update_config=1

network={

ssid=”NETWORK-NAME”

psk=”NETWORK-PASSWORD”

}

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 https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html 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:

  • Download git and pip3 by running “sudo apt-get install git python3-pip”.
  • Download the code from my Github by running “git clone https://github.com/Psuedohim/ARCRobot/”

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 go_auto.py

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

 

That 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:

WordPress.com Logo

You are commenting using your WordPress.com 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