If you have been following along with me from the last tutorial, you are already familiar with the structure of a differential drive robot. Those of you who are looking to actually build a robot might already have a differential drive robot chassis assembled (something that looks similar to picture 1. However, if you have just stumbled upon this post, you might consider having a look at the previous post – Building the first Robot
.Picture 1: Differential drive robot
So let’s talk about robots in general and what they are supposed to do in our world. The guys at Wikipedia say that any machine capable of carrying out complicated series of tasks on its own is defined as a robot. So, we can literally define a lot many things around us as a robot (see picture 2).Picture 2: Various Robots
I guess the images above already made you excited about building your own robot. But, to begin making robots, we will first need to decide what our robot should do. We might simply start with a remote controlled car that you can play with and call it your robot (that indeed is the easy approach). Instead, let’s challenge ourselves by making something way smarter – an autonomous robot. In this blog, we will start with building real robots – machines that are intelligent and can take decisions themselves.
The main ingredient of intelligence is the brain. We can move around, read, talk, dance and are able to do all those geeky stuff just because our brain processes various inputs (from our sense organs) and produce various outputs (movement of muscles, winking of eye etc.). So, in a nutshell, if we want our robots to do significant tasks on its own, we need to find it a brain. Don’t freak out because it is entirely possible. The brain on a robot is an electronic chip known as a microcontroller (see picture 3).Picture 3: Microcontroller
These integrated chips (IC) can take inputs and process the input to produce various outputs. Some of the very famous microcontrollers available around ranges from simple 8 bit Atmega series microcontrollers to the high end ARM processors. Though learning microcontroller programming (embedded systems) is often intimidating to beginners, it is definitely not rocket science. And as a roboticist, this is one of the indispensible skills you will require to make robots that you are really proud of. To make the learning process easy and quick, many development boards based on different microcontrollers are available in the market. To begin with, I am choosing the famous Arduino (Atmega based development board) as the brain of our robotic projects.
Arduino as shown in picture 4 contains the Atmel’s Atmega microcontroller. It is an 8-bit controller which is powerful enough for a large array of robotics projects. However, if you want to use another microcontroller you can follow along as the concepts remains the same. Also, we have separate tutorial series on MSP430 microcontroller which is a widely used 16 bit controller from Texas Instruments.Picture 4: Arduino UNO
If you haven’t already purchased an arduino, you can have a look at the useful reference section to find a supplier. Also, if you find arduino rather expensive (nearly INR 1500), you can go for an arduino compatible board which can be easily found with a quick Google search. Let’s now understand what is inside an arduino.Picture 5: Arduino board description
As you can see in the picture above, the arduino consists of:
All Arduino boards have an Atmel’s AVR series of microcontroller (Atmega 8/ Atmega16/ Atmega328). This is an 8 bit microcontroller with flash memory space of 8 KB, 16 KB or 32 KB. Believe me you don’t need to know any of this right now!
2. Digital Pins
The rail of black female headers as shown in picture 5 is the digital Input/Output pins. These are what make your microcontroller board really useful. By learning to program these pins you can do all sort of things from lighting an LED to driving motors and much more.
There are four on-board LEDs (Light emitting diode). The power LED lights up when the board is powered. Two LEDs are connected to Tx and Rx lines for easy visualization of serial communication (You will understand this in later tutorials). One LED is hard-wired to the digital pin 13.
The reset button is used to reset the board when something goes wrong or when we need to re run the program.
5. USB jack
It is used for powering the board through USB cable, uploading instruction and for achieving serial communication which the computer.
6. Power jack
When you have connected your board to your PC, it drew power directly through your computer. However, if you are developing a standalone product, you might not want to have your computer around. In this condition, you can use an adapter or a battery connected to the power jack to power up your arduino.
7. Analog input
What good is a microcontroller if it cannot understand the world around us. And when it comes to understanding the world, we have many different sensors available for our rescue. The analog input pins on the arduino helps in interfacing sensors that give analog voltage as its output. Don’t worry if you did not understand this well right now as we will be spending a lot of time in using and programming these pins.
8. Power pins
The power pins can be used to supply 5V or 3.3 V voltage to your external circuits.
Now that you understand a bit about your board, it’s time we start using it. The arduino requires computer programs to use and control its various functionalities. These programs can be written in software known as Arduino IDE. To download the arduino IDE, you can use the below link.
Once you have downloaded the arduino setup file (see picture 6), you need to double click on it to initiate the installation process. The installation is now self explanatory. Picture 7 – 14 guide you through the process.Picture 6: Arduino setup Picture 7: Welcome screen
Picture 8: Select location for installing Arduino
Picture 9: Check in all additional tasks
Picture 10: Setup ready to install. Press Install.
Picture 11: Installation going on
Picture 12: Install drivers
Picture 13:Accept warning and click Yes
Picture 14: Driver installation complete
Picture 15 shows the Arduino IDE. It is the platform on which we write program that we want our arduino to execute. Also, using the arduino IDE, we send the program from our laptops to the arduino board. Let us now try to understand what different windows on the arduino IDE mean (see picture 15).Picture 15: Arduino IDE
Now that you are familiar with the arduino IDE, let’s get started with our first program. In the language of computer science, the first program someone writes while learning a language is to print “hello, World!” on screen. In the world of microcontrollers, we don’t have easy access to display monitors. Therefore, here “Hello, World!” would mean a blinking LED. Our task will be to blink the on board LED on Arduino which is connected to the pin number 13. For this, open up the blink program under file/Example/Basics/ as shown in picture 16.Picture 16: Opening blink program
Once the program has been written, the next step is to select which board you are going to put the program into. For this, go to Tools/Board/YourBoard as shown in picture 17. Once the board is selected, you need to select the COM port that your computer has assigned to the arduino board (look in the device manager). The COM port can then be selected by going in Tools/SerialPort/COM_number as shown in picture 18.Picture 17: Selecting the right board Picture 18: Selecting the right COM port
Once the correct board and COM port has been selected, you can then upload the program to get the blinking LED by hitting the compile and upload button as shown in picture 19.Picture 19: Uploading the program
If everything worked correctly, then congratulations! You just made your arduino board work. I understand that this has been a lot of work. So lets stop right here today. Next day, we will be delving deeper into what is inside the program that made your LED blink. Also, we will be making changes to the program to produce our our blinking patters.
Till then, Happy Making!