Basic Robotics

Welcome to the GearsNGenes Basic Robotics course!

One of my (Sidharta Vadaparty) earliest projects with Arduino was with building robots, as they were a huge influence for me getting interested in programing at all. In fact, one of the most popular pages here on GearsNGenes seems to be the one documenting my earliest video and instructable on building a 2-wheeled robot that you could control with an IR remote. So it is no surprise that robotics hold a special place in the heart of GearsNGenes.

This course serves to provide a beginner level introduction to robotics.

The Robot Family Tree

The below family tree indicates the kinds of robots we will cover in this course and how they relate to one another. We start with showing how to build a basic robot that can move in hardwired paths, then we explore how to drive a robot through various sensors.

Hardware Resources

Throughout the course, there are some pieces of hardware that you will need for all of the robots.

Chassis

Throughout this course, we will be using a single standard robot chassis, but any two-wheeled robot chassis will also suffice. This chassis in particular is called the mini round robot, provided by Adafruit Industries. The chassis can be bought here.

This chassis is perfect for someone looking to get started with robotics as it requires no soldering and very little screwing.

On a separate note, the Acotbotics kit ActoBitty is an equally acceptable chassis to get started with this course.

PCB

Additionally, GearsNGenes developed a PCB built for this course. This board is designed to be a featherwing, meaning you can stick any Adafruit Feather microcontroller into the designated space. The board also provides breakouts for three sensors (seen on the right): two I2C sensors and one ultrasonic US-100 sensor (rightmost set of solder holes).

The PCB has three screw holes marking the front (the right on the image below) and one screw hole on the back (left).

There are breakouts for other output and input pins as well, as seen in the image below. The PCB can be bought on Oshpark here.

Attaching the PCB to the Chassis

To attach the PCB to our Adafruit robot chassis, see the image below and its associated key.The PCB has three screw holes on the front and one screw hole on the back. See the image of the top of the robot chassis to follow along with how the screw holes on the PCB correspond to it.

Green: These three slots are spaced to fit the three front screw holes of the PCB. The screws must be aligned, but there is room to slide the PCB if you feel

Blue: If you don’t want to screw in all three screw holes and only the middle front, then either of these two holes will suffice.

Pink: Either of these holes correspond to the back screw hole of the PCB. Note that if you use one of these holes, then you must use the corresponding blue hole. The left pink corresponds with the left blue, and the right with the right.

Software Resources

All of the code for this course is written in Arduino. All the necessary code is accessible through GearsNGenes’ github.

The repository for this course specifically can be found here. Any new libraries you might need to install will be indicated with each project.

Your First Robot Program: Basic Movement and Speed Control

This project explores the GnGBasicRobot Library, the bread and butter of this course. When you are done building this project, you should be able to:

  • move your robot back and forth and left and right (in place or pivot turn)
  • control the robot’s speed
  • program basic paths for your robot to follow

Hardware Materials

For this project, you need:

  • Your robot PCB
  • Your Robot chassis
  • A Pololu TB6612FNG H-Bridge, this is your motor driver
  • An Adafruit 32u4 Basic Proto Feather

Software Materials

The code for your robot can be found in the course’s repository marked as “01_GnGBasicRobot_Basic_Example“. This has two files in it: an example arduino file with a matching name as the project and a folder with the GnGBasicRobot Library. When you download this project, put your GnGBasicRobot folder in your Arduino IDE’s libraries folder. This will allow you to use GnGBasic robot for any future projects.

The Interface

When you open 01_GnGBasicRobot_Basic_Example.ino, you find example code of how your robot works on the most general level. Here are some of the basic commands you need to know in order to use this library:

  • #Include <GnGBasicRobot.h>: this simply includes your library in the code so you can access it.
  • GnGBasicRobot robot1: Calling GnGBasicRobot is effectively calling the constructor method of a class. It has no parameters, so no additional parentheses are needed in the call. “robot1” is the name we picked for the robot, but it can be any name, such as “robot” or “steve”.
  • .setUp(): this method handles setting all of your robot’s control pins to the correct settings and values. The constructor method calls this automatically, but you can call it externally, as well.
  • .setRobotSpeed(int speedVal): this method allows you to set the relative speed of your robot. The integer must be a value between 0 to 255, inclusive. This value is then sent to a PWM pin on the feather to control the speed at which the robot’s wheels turn.
  • .moveRobotForward(int delTime) and .moveRobotBackward(int delTime): these methods move your robot forward and backward respectively for a number of milliseconds equal to the amount specified in the arguments (delTime). The default value of delTime is 500.
  • .turnRobotRight(int delTime) and .turnRobotLeft(int delTime): These rotate your robot right and left respectively for delTime milliseconds. The wheels move in opposite directions so that the while the robot turns, its center remains in place.
  • .pivotTurnRobotRight(int delTime) and .pivotTurnRobotLeft(int delTime): these methods turn your robot right and left respectively. Unlike the previous methods, however, the robot does not remain in place. Instead, one wheel moves forward while the other remains still, moving the robot’s center.

Optional Challenge

Feel free to experiment with these methods and see what kinds of crazy paths you can code your robot to make. As a challenge, try to code your robot to move in a perfect square path!

There are other methods you can check out in the GnGBasicRobot Library, but for now, this concludes our introduction to the Basic Robot! Keep reading to see more projects in this course!

Your First Sensor: Obstacle Avoidance With An Ultrasonic Sensors

In this project, we code our robot to receive input from an ultrasonic sensor (specifically called the US-100). This sensor uses sound to determine how far away an obstacle is from it (if there is one at all). With this project, we can make a robot:

  • keep track of the distance of items in front of it
  • stop and turn away from obstacles that get too close

GearsNGenes Euglina: A Light-Guided Robot

In this project, we make the robot steer in the direction of bright light, much like how the photosynthetic organism called euglena searches for light. To enable such steering, we use Adafruit Industries’ BH_1750 light sensors. We code our robot to listen to two of these sensors, one placed on the left side of the chassis and the other on the right. The sensor receiving more light, above a certain threshold, determines whether the robot turns left or right.

GearsNGenes Bluetooth Robot

Our final project puts Bluetooth controls on our GnGBasicRobot. We use GearsNGenes’ Bluetooth libraries and the free-to-download Adafruit Industries Bluefruit app to enable Bluetooth communication. With this project, we make a robot:

  • detect us press buttons from the app on our phone
  • change the speed and direction based on which button we press

The true power of the GearsNGenes Bluetooth libraries is the variety of sensors that are available for you to experiment with. On the Bluefruit app, there are a variety of sensor and control options such as:

  • A color picker
  • A button pad, which our project uses by default
  • An accelerometer
  • A gyroscope
  • A Magnometer
  • And more.
Scroll to Top