When you start with something new you often stumble across words you have never heard of before. This tutorial aims to cover the basic terms used when talking about the Arduino. Ready to learn what a microcontroller actually is? Just read ahead!
Let's start with Arduino itself. Often when someone says 'Arduino' a specific board is meant, the Arduino Uno. Arduino itself is much more than just this board. The Arduino platform includes hardware and software, as well as a huge community with lots of project ideas.
What's so special about Arduino? Why is it so popular? The Arduino platform is specifically designed to be easy to use. Traditionally you had to buy a separate device called a programmer to upload your code to a microcontroller. For different microcontrollers you might need different programmers too. To actually write a program you had to buy the manufacturers' software package or manually set up a toolchain for compiling your programs.
With the Arduino you don't need to do that. Arduino boards typically integrate a USB interface to program the microcontroller without the need for extra hardware. The free Arduino IDE can be used to write your programs, compile and upload them to the Arduino board. There is no need to set up a compiler yourself. Additionally, Arduino tries to offer a consistent way to program different microcontrollers. There is a simple-to-use collection of functions that can be used mostly independent of the actual board. This makes it easy to get started with new boards and migrate existing projects to it. These concepts make Arduino so popular.
The original Arduino boards are produced in Italy. You can find everything you need to know about the boards on arduino.cc. The Arduino design files are publically available and the software is open source. This allows other manufactures to produce their own Arduino boards and integrate them into the Arduino IDE. If you want to you could build an Arduino yourself.
IDE stands for integrated development environment. An IDE integrates all the software components needed to write, compile and upload your code to the microcontroller. The Arduino IDE is a pretty basic editor. It comes with syntax highlighting, but misses more advanced features like autocompletion. The upcoming Arduino IDE 1.9 will finally integrate this feature. Still, the Arduino IDE cannot compete with professional IDEs like Visual Studio or Eclipse. Nevertheless, the Arduino IDE includes everything you need to get started. It includes a compiler and drivers for the boards produced by Arduino itself. Libraries and compilers for boards from different manufactures can be installed through the integrated board manager. Using the IDE you can write your program and upload it to the board with a single click.
The Arduino Uno is the most popular Arduino board. Most projects and extension boards target this Arduino board. It comes with an ATMega328P microcontroller which features 32 KB flash, 1 KB EEPROM, 2 KB RAM and runs at 5V with 16 MHz clock speed. It uses no operating system and can only execute a single program at a time. The 32 KB flash is used to store your program while the EEPROM can be used to store configuration or measurement data. The EEPROM can be written more often and is usable in a more flexible way than the flash. I might explain the difference a bit more detailed in a later tutorial, for now it's enough to known that your program is stored in the 32 KB of flash once you upload it to the device.
If you look at the figures I gave you, you might ask yourself why someone wants to use a platform with that little computational power. Here is what differentiates a microcontroller from a PC or a Raspberry Pi.
Your PC and even a Raspberry Pi are way more powerful and have more RAM and storage space. There are also less powerful microprocessors, but they have one thing in common with your PC or a Raspberry Pi: They expose an external bus to connect RAM and storage. Microcontrollers don't do this, they have integrated RAM and storage. More importantly, they integrate I/O peripherals as well. The Arduino Uno for example includes Analog-to-Digital-Converters (ADCs) as well as digital I/O pins that can be controlled by software. The ability to control things using the integrated I/O peripherals is what gives microcontrollers their name. To sum up, while microcontrollers have less computational power they do provide everything needed to control external components and circuits. Let's have a look at what the Arduino Uno provides, shall we?
Normally you power the Arduino Uno using the USB Connector. There is however an alternative way to that by using the DC jack. This is typically used to power the Arduino Uno from a 9V battery. You can supply a voltage between 7 V and 12 V using the barrel connector.
The Arduino Uno uses a USB-to-serial converter because the ATMega328P has no support for USB. The converter is used to talk to the Arduino from your PC and you can use it in conjunction with the serial monitor in the Arduino IDE. It is also used to program the Arduino Uno from your PC.
Why do I tell you all this? While the converter does it work in the background without you noticing it, it might require you to install a driver on your PC to use it. A missing driver for this chip might be the reason why you can't program the Arduino Uno form your PC. But no worry, I will teach you how to install the Arduino IDE and the required drivers in the next tutorial.
The Arduino Uno features fourteen digital pins and six analog pins. The term pin itself, refers to the exposed metal pins of the microcontroller itself. They are connected to the chiplet housed inside the plastic case and allow you to connect to external electronic components.
All pins can be used as digital input or output. Digital pins allow only two states referred to as high and low or 1 and 0. You can use a pin as an output and programmatically connect it to either 0V or 5V, where 0V is low and 5V is high. The Arduino Uno can drive a current of 40 mA per pin but no more than 200 mA in total. You can also use these pins as an input. In this case a voltage lower than 0.5 V is read as 0 and a voltage above 4.5 V is read as 1. A voltage in the range in between this two states produces an unspecified result and will be read as either 1 or 0. This might be a caveat for you if you directly connect a button to an input pin of the Arduino. In this case you have a clear 0V if you press the button, but an unspecified state as long as it is not pressed. If the button is released nothing is connected to the pin, it is neither connected to 0V nor to 5V. This is called a floating pin. If you happen to have one of those they might drive you crazy while searching for errors in your code. To avoid this situation the Arduino provides an internal 20-50 kΩ pull-up resistor which can pull the voltage of the pin to 5V if the button is not pressed. I will tell you how to use it once we get there.
The six special analog pins enable you to sense voltages. They can sense a voltage between 0V and 5V. This voltage reading is converted into a number between 0 and 1023 where 0 is 0V and 1023 is 5V. If you don't have a stable 5V supply voltage you can also use the internal 1.1V reference voltage and sense voltages between 0V and 1.1V. This can be used to determine the current battery voltage.
There are some more special pins. The two I²C pins SDA and SCL allow connecting digital sensor modules to the Arduino Uno. The UART pins (RX and TX) allow you to talk to another Arduino, a Raspberry Pi or a similar board just like you can communicate with your PC through the USB-to-serial converter. There is also an integrated LED which is connected to pin D13.
If you want to do more than just playing with the onboard LED without designing your own circuits, you can use shields and modules. Shields are extension boards with additional components, which can be stacked on top of the Arduino Uno board. The shield will exactly fit into the headers of your Arduino board.
Modules are another way to connect external components to your Arduino board. A module is a PCB with all components required for a sensor or actor. To use it with your Arduino you just connect it using some jumper wires. Modules and shields usually come with a description how to wire and use them. You will probably find more than enough resources on the internet. I will cover some modules and shields in future tutorials too.