Introduction: RUMI the LineFollowingRobot

About: I am a maker who wants to share my journey of creating with the world. I was born and raised in Belgium, more specifically Ghent. I have a bachelor’s degree in automation and I am working towards a master’s d…

I made this project in collaboration with Ruben Says, for our studies in electromechanics at the HoGent. The assignment was to make a line follower robot, which is a little cart that by using its sensors is able to follow a black line on a white paper.
In this tutorial I will give you an inside look in how to make this robot, so you can understand how this robot is working and you should be able, by following the steps, to make it yourself. All the files that I made and used for this project are of course available for free.

Hopefully you will find this interesting, let's begin!

Step 1: Choose the Key Components

The Specifications:

The objective is to create a small, 'cheap' (=max. 50 euros), lightweight, line follower robot. It must include a light sensor array with a PID controller, which can be tuned via a wireless connection. It should reach a speed of >0,5 m/s and should be able to continuously follow a printed track (printed black lines on a white paper). Those printed tracks are 1,5 cm wide, have a minimal radius of curvature of 10cm and can contain crossroads, in which case the robot should go straight forward. You can find the files of the tracks below. Other constraints are the height and width of the robot that shouldn’t be more than 12cm and we should use as much smd components as possible, rather than using through-hole components.
In summary: the Hardware should consist out of:

  • Energy source
  • DC-Motor's
  • H-bridge
  • 6 Analog Light sensors
  • PID-Control
  • Wireless Communication
  • Start/stop button

Choosing Key Components:

With these specs in mind we started our brainstorm session and made the first big decisions: We decided to use 6V DC motors and a 50:1 gear. We chose the 6V mainly because we wanted to use two 18650 batteries in series as a power source. Because those batteries are a relatively light, easily available, powerful and cheap option for this project. The batteries provide a voltage between 7.4 and 8.4 volts. Taking losses into account this means that it won't overload a 6V motor while delivering enough amps.

Using the ATmega32u4 microcontroller as the brains for the robot (the chip used for the Arduino Leonardo board) was an obvious choice, as it should be able to compute all the calculations needed for this project. This chip will be connected with some in- and outputs:

The chip should get two inputs: a light sensor array and a 5 volts. For the light sensor array we went with the QRE1113 sensors, as their specs fit our specs and are commonly found in likewise projects. We will be using six of those. The five volts will be delivered through a voltage DC to DC regulator reg1117, because it is an easy to find smd component and fits our description.

The chip has one major output: the H-Bridge. We opted for the DRV8833, as this was the first smd H-bridge we came across that met our specifications. Probably there are way more good alternatives out there, but why look further if you got what you need?

The chip has two communication lines (In/Out), one through usb and one via bluetooth. For usb we went with a mini USB port mainly because it solders on more easily than a micro USB port. For the bluetooth we chose the HC-05module, as I had one laying around anyway, these modules are easy to come by and work perfect for this application.

Step 2: Design Electrical Circuit

For this project we wanted to design our own circuit board, which was a thing to keep in mind when designing our electrical circuit. We ended up using the 'Eagle' software to create our circuit, because it is relatively easy to work with, freely available and it allows the creation of pcb design that can later be printed.(

Another advantage of this software is that is has already quite a big component library and when they don't have the component needed somebody else probably already did create it, which then is easily imported into the software. For example on SnapEDA as shown below:

Regarding the creation of the pcb, it was important that when inserting a component, we picked a component with a good footprint. This made the initial process of creating the electrical circuit a little harder, but paid off big time in the next step. To make a good decision, there are a few things you have to keep in mind. Starting with the main take-away: We wanted it to be as small as possible, so the robot would be as small and compact as possible. However, we are not always able take the smallest component; there are a few limitations:

    • We want to use smd components so we can make an optimal use of both sides of the pcb. So watch out not to use the through-hole footprints.
    • Does the component you want to use exist, and is it easily available? This is a question you should answer for every new component you add, just run it through google and/or a sellers website and check if the specifications match your needs in the datasheet. Don't forget that smaller components often have lower rated voltages, so make sure that checks out as well.
    • It also happens that a slightly smaller component exponentially rises in price, then you have to take into consideration if that rise in price is worth the minimal win in size.
    • Keep in mind we are not robots and we have to solder it by hand. So even though it is possible I really wouldn't suggest using components smaller than the 1206 footprint.
    • More on this topic I found on this website:

    In hindsight we should have used a bigger footprint and component for the crystal, because even though it worked, we had a hard time soldering it onto the board and we managed to destroy one.

    As you can see I divided the circuitry into five schematics, where I will briefly shed some light on.

    1. The first schematic is built around the voltage regulator for the ATmega32u4 (REG1117). The atmega likes to receive a nice 5 dc voltage, to achieve that the voltage regulator transforms the unstable input to a relatively stable 5 volts. To increase that stability we use ‘snubbers’, which are the 100nF capacitors (to remove spike voltages and electromagnetic interference) and a smoothing capacitor, the 100μF capacitor, (to keep the battery voltage as stable as possible). We also wanted to be able to power the board without batteries when connected to the pc, therefore we implemented a jumper to switch between the two sources. Finally there is a status led, to tell us when our circuit gets power, this led has of course a ballast resistor.

    2. The second schematic handles the brain of the robot, which need more components than just the ATmega32u4 IC. For starters it needs a clock signal in the form of a timing crystal, this crystal should create a frequency of 16MHz for the ATmega to work properly. In addition to the crystal there are also two 22pF load capacitors and a 1M ohm resistor needed. The crystal is a quartz and is therefore a piezoelectric material. This means that when a certain voltage is applied, it resonates at a particular frequency. For it to work like a metronome properly, every cycle should have a phase shift of 360°, because we want the signal not to interfere with itself. To accomplish this there is an RC circuit (1M ohm and 22pF) which gives you a certain shift and the two load capacitors in series from the crystal point of view which finalise the shift. The lower the combined capacity of the load capacitors is, the higher the produced frequency of the Crystal. The higher the combined capacity, the lower the produced frequency.

    We also wanted to add a usb port for data communication. This is just a straightforward connection D+ to D+ and D- to D-, but there have to be some termination resistors in between so the total impedance of the connection matches the usb specifications. SW2 is the reset switch of the ATmega. SW1 is a programmable switch, which will later be programmed as the start/stop switch. LED2 is a programmable light that in the end doesn't really has an important function, but will be very helpful in verifying that everything works.

    One very important thing you can't forget is to give all the ISCP pins a terminal, so you can connect them later to upload the bootloader. Those pins are the SCK, MOSI, MISO, VCC, RST and GND pin.

    3. As it would be kind of unhandy when every time we want to change a setting we have to plug it into a computer, we wanted to implement some bluetooth functionality. We chose the HC-05 module.(Datasheet:

    This bluetooth module is powered with 3.3V, so we needed another voltage regulator, and again used a REG1117, yet this time a model that gives a steady 3.3V output. Just like before we added a status light, some snubbers and a smoothing capacitor, to create a clean output voltage.

    For the date transfer we need to connect the TX to RXD and RX via a voltage divider tot TXD. The voltage divider needs to transform de 5v data line from the Arduino to a 3.3V data input from the HC-05 (This is not needed in the opposite direction because the Arduino can read a 3.3V incoming signal. Finely there are three more components: a switch and two more status lights:

    • PIO8 is used to control LED indicating the status. It will blink after power is on.
    • PIO9 is used to control LED indicating paring. It will be steady on when paring is successful
    • PIO11 is used to set this two mode: AT command mode (if the pin is connect to 3.3V) or Automatic binding transparent data mode (if the pin is connect to GND). The AT command mode is used to configure some characteristics of the device (for example the Master, Slave or Loopback modes). (

    4. The Sensor Array is quite straight forward as the QRE sensors are not much more than a led with a current-limiting resistor and a phototransistor that is connected to a pull-up resistor (47k) to form a voltage divider that produces an analogue voltage output between 0 V and 5V.

    5. At last we have the H-bridge, which is an electronic circuit (IC) that switches the motors on, off, forward or backwards. For the H-bridge I just followed the recommended circuit found in the datasheet (, this example adds some smoothing capacitors for the incoming voltage, some resistors for disabling the sleep function and enabling the outputs. The inputs are connected to Pin 5, 6, 9 and 10 of the Arduino, which are all pwm pins, what is crucial if you want to adjust the speed.

    Finally it is a good idea to check your schematics with an ERC check, this won't verify if your circuit works, but it will verify if everything is connected properly. If this is all finished we can move to the next step: Turning this into a printable pcb.

    Step 3: Design the Pcb

    Now that we have our circuit we can start the most demanding part of the build, creating the pcb. To start this click in eagle on "switch to board" and you'll get an empty board with all the components, used in your schematics, next to it connected with tiny lines showing where to make the connections. This was my first attempt on creating a pcb, but as it is not the objective for this Instructable to guide you through designing a pcb, I'll just point out a few things that are challenging and you can't forget when designing these. If you just want to get building you can just skip this step.

    For me the best approach at this was to first place al the big and main components on both sides of the board. There are immediately some components I was able to give a place by thinking logically: I definitely wanted the leds, the motors, the switches and the jumper on top of the pcb. The sensor array on the other hand obviously had to be on the bottom. The ATmega and the HC-05 I liked to have somewhere in the center and the H-bridge on a somewhat equal distance from the ATmega and the two motors.

    Then there are a few things you have to take into a count:

    • The Smoothing capacitors have to be as close as possible to the voltage regulators.
    • The Snubbers have to be as close as possible to every vcc input of the ATmega (Thats why there are so many).
    • The crystal and its components should also be as close as possible tot the ATmega.
    • Plaats de usb connector en bijhorende weerstanden zo dicht mogelijk tegen de microcontroller.

    Some other guidelines that will help you making a working pcb is the following:

    • Draw in mil’s not in mm.
    • Grid: 25 mil
    • Width tracks: min 12 mil for logic tracks, power tracks must be thicker.
    • Short and thick tracks are always beter then long and thin ones.
    • Making via's is beter then long tracks around the pcb.
    • Make the circuit so compact as possible.
    • Drilling with 0,6 or 0,7 mm holes.
    • To create a ground surface:
      • Draw a polygon around the pcb.
      • Name it GND.
      • Then press Ratsnest.
    • Don't forget to do a DRC check, to check if everything is connected.

    Following all these rules and after hours of intensive work I was able to get the result you can see here.

    Finally there was one more esthetical decision to make: "a front spoiler!" To make this happen I drew two circles with there center point equally far away from the center of the pcb. Then I started drawing holes along the lines of those circles. At the point where the sensors are situated I continued to draw the holes around those sensors, thus creating a spoiler. This is one of the details that makes RUMI so unique.

    Step 4: Order Components

    We already knew what our key components where going to be, but now that we designed our pcb we know all our other components and are ready to order them online. After some research we found that Mouser was able to deliver almost all our components in a timely fashion, as there was some time pressure. If you have time for this project I would suggest using online stores like eBay or AliExpress, where I had bought the bluetooth module and the battery charger modules already a while ago. The 18650 batteries I salvaged from a dead battery pack I took out of an old computer. The standoff bolts and the piece of plexiglass I got from a local hardware store.

    The pcb you can order on a website like:

    1. Add the Gerber and drill file I put as an attachment or the files you created yourself.
    2. All the standerd settings are fine as they are, unless you want to pay extra for a different color pcb.
    3. Now you can just order them.
    4. Wait and they will arrive surprisingly quick.

    For the components:

    Listing all our components also raises the question, what it cost to build this robot if you have nothing laying around. We ended up paying 75,64 euro's this includes everything + shipping (But it doesn't include the piece of plexiglass). When we would have had more time to build this, you can easily build this for less then 50 euro's (shipping cost of the pcb is 8 euro's instead of 21 euro's, Motors on AliExpress cost a fraction of the 20 euro's we payed for them).

    Step 5: Assembling the Pcb

    Now that all the parts have arrived we can start the assembling proces.


    • Soledering station.
    • Tweezers.
    • Solder.
    • Solder wick.
    • Flux.
    • Multimeter (two test leads).
    • Circuit board holder or helping hand.
    • Delicate task wipers, a brush and KONTAKT-SR or isopropyl alcohol.
    • Solder mat.
    • Hot air gun (Optional, If you use it be very careful and use a small diameter)

    Plan of action:

    Before starting I printed out the schematics so I was able to keep track of what I was doing.

    The first component we solder to the board is het the usb connector, first solder the ground pads to the board. Add some flux over the pins, then bridge all the pins with a lot of solder, then go over it with the solder wick. Finish it by cleaning the exces solder with some wipers, a brush and isopropyl alcohol. Now take the multimeter and check if you can measure 5 volts in the circuit till the jumper. Next solder the jumper to the pcb. When connecting the 5v to the vcc, you now should be able to measure 5 volts over the entire circuit. Now solder the crystal, the two lead capacitors and the 1M ohm resistor to the board. Check if you still measure 5 volts.

    Now it is time to solder the ATmega to the board. First aline the Ic with the little dot in the upper left corner, then solder one pin on each side of the square. Next flood al the pins in flux, next bridge al the pins with a ton of solder, then go over it with the desolder wick. Finally clean all the extra flux with some isopropyl alcohol. Then solder the UCap (c10) and I also prefer to already solder c4, c5, c6 and c7 those last ones are not necessary but it won't hurt either. As always check if you still measure 5v everywhere. Now you can connect the board to a pc and if everything went good it will recognise the Arduino in the device manager.

    After this the hardest part has passed and you can continue by adding the H-Bridge, the sensor array, the leds and the bluetooth module. Of course don't forget to measure after every step. Finally we want to add the voltage regulator for the batteries and can verify if this works by connecting the batteries for the first time (Don't forget to switch the jumper) and you can again measure if everything is powered on correctly.

    When everything went according to plan we can move to the next step, burning the bootloader.

    Step 6: Burn the Bootloader

    If everything went right, when you plug in the pcb into the computer it will discover the atmega under other devices in the windows device manager. This means everything is working properly, but it will not jet recognise the Arduino in a COM port. To accomplice this we will have to upload the bootloader. Basically you just have to connect the ICSP connectors from the Arduino Uno with the robots corresponding pads. I also made a little circuit that gives me a little more info on how the upload is going. All info and the place where I learned it is on this website:

    Step 7: Recharger

    To recharge the two 18650 batteries I made a very simple charging dock. It is made with three components a universal perfboard, two Mini USB charging modules ( and a dual 18650 battery holder ( The positive terminal of the USB charging modules is connected with the positive terminal of the battery holder. The negative terminal is via the perfboard connected with the negative terminal of the battery holder. In this case the two circuits are completely separate. When you have more time on your hands, I would suggest making a circuit that recharges the batteries with just one Mini USB wire. For the making it a little more handy I used a 5V powered usb splitter to power the usb modules.

    Step 8: Write the Program

    When your robot is fully working it is time to write, or just upload, the code (you can download our code).

    The code was entirely written by Ruben and he wrote his explanation of the code in Dutch:

    "Dit is de arduino code die werd gebruikt bij ons project. Van lijn 1 tot lijn 3 worden de gebruikte bibliotheken ingeladen. op lijn 5 wordt de SerialPort gedeclareerd (Serial voor pc monitor, Serial1 voor HC-05 bluetooth module).

    Lijn 7 tot 40 worden alle variabelen aangemaakt voor programma. In de setup worden de ingangen en uitgangen gedefinieerd en worden commando’s aangemaakt. Er zijn 7 commando’s: sCmd.addCommand(“start”, onStart); voor het startensCmd.addCommand(“stop”, onStop); voor het stoppensCmd.addCommand(“set”, onSet); voor veranderen van variabelen in struct param_t.sCmd.addCommand(“debug”, onDebug); uitlezen van waardensCmd.addCommand(“reset”, onReset); waarden van struct param_t resettensCmd.addCommand(“calibrate”, onCalibrate); voor het kalibreren van de sensorensCmd.setDefaultHandler(onUnknownCommand); voor onbekende commando’sin void loop() wordt er eerst gekeken of er seriële commando’s werden doorgestuurd. De waarden van de sensoren worden uitgelezen met analogRead(). Vervolgens worden deze waarden genormaliseerd en geïnterpoleerd (met gewogen gemiddelde), dit is nodig voor het detecteren van de zwarte lijn. Vervolgens word de PID controller aangemaakt, en als laatste de motoren aangestuurd aan de hand van de PID output."

    Step 9: Finalising the Build

    Now that we have a working pcb we just need to add a few extra pieces to make it a fully functional robot.

    To start we have to attach the motors to the pcb, for that I bought a fitting bracket ( There are four predrilled holes in the pcb for bolting on those two brackets. Then there is a predrilled hole for a bolt in the front that is used as a front support, that also makes it possible to adjust the hight of the sensors above the ground.

    There are three more predrilled holes where the three standoffs go, to add on top of this I made a custom acrylic plate which holds the battery holder. The acrylic plate is made so it has the same curves as the pcb, what gives it a more streamlined look.

    Finally we finished it of with some cable management using some zip ties.

    Step 10: Finetune & Enjoy

    Next I downloaded this app (, which makes it possible to connect to RUMI. This app makes it able to change the parameters saved in the eprom memory. So you can achieve an optimal result, this isn't easy because of multiple variables like light, the charge of the batteries, etc.

    In the video below you can see our very first round:

    Future plans: It would be nice if when we get our robot back we can still achieve the following goals:

    - Updating the program and parameters so we can reach at least 0.5 m/s.

    - Creating a dedicated app for our robot.

    - Creating a tutorial video on how to make this yourself.

    PCB Contest

    Runner Up in the
    PCB Contest