Introducing the Arduino:
The Arduino is a small computer that you can program to read information from the world around you and send commands to the outside world.
You can do amazing projects with it, there is no limit for what you can do, and using your imagination everything is possible!
What is an Arduino?
The Arduino is the board shown in the figure below.
Basically, it is a small development board with a brain (also known as a microcontroller) that you can connect to electrical circuits.
This makes it easy to read inputs – read data from the outside – and control outputs – send a command to the outside.
The brain of this board (Arduino Uno) is an ATmega328p chip where you can store your programs that will tell your Arduino what to do.
Exploring the Arduino Uno Board. In the figure below you can see an Arduino board labeled. Let’s see what each part does.
2. Digital pins: Arduino has 14 digital pins, labeled from 0 to 13 that can act as inputs or outputs.
3. When set as inputs, these pins can read voltage. They can only read two states: HIGH or LOW. When set as outputs, these pins can apply voltage. They can only apply 5V (HIGH) or 0V (LOW).
4. PWM pins: These are digital pins marked with a ~ (pins 11, 10, 9, 6, 5 and 3). PWM stands for “pulse width modulation” and allows the digital pins output “fake” varying amounts of voltage. You’ll learn more about PWM later.
5. TX and RX pins: digital pins 0 and 1. The T stands for “transmit” and the R for “receive”. The Arduino uses these pins to communicate with other electronics via Serial. Arduino also uses these pins to communicate with your computer when uploading new code. Avoid using these pins for other tasks other than serial communication, unless you’re running out of pins.
6. LED attached to digital pin 13: This is useful for an easy debugging of the Arduino sketches.
7. TX and RX LEDs: these leds blink when there are information being sent between the computer and the Arduino.
8. Analog pins: the analog pins are labeled from A0 to A5 and are often used to read analog sensors. They can read different amounts of voltage between 0 and 5V. Additionally, they can also be used as digital output/input pins like the digital pins.
9. Power pins: the Arduino provides 3.3V or 5V through these pins. This is really
useful since most components require 3.3V or 5V to operate. The pins labelled as “GND” are the ground pins.
10. Reset button: when you press that button, the program that is currently
being run in your Arduino restarts. You also have a Reset pin next to the power pins that acts as reset button. When you apply a small voltage to that pin, it will reset the Arduino.
11. Power ON LED: will be on since power is applied to the Arduino.
12. USB jack: you need a male USB A to male USB B cable (shown in figure below) to upload programs from your computer to your Arduino board. This cable also powers your Arduino.
Downloading the Arduino IDE:
The Arduino IDE (Integrated Development Environment) is where you develop your programs that will tell the Arduino what to do.
You can load new programs onto the main chip, the ATmega328p, via USB using the Arduino IDE. To download the Arduino IDE,
click on the following link: https://www.arduino.cc/en/Main/Software.
Select which Operating System you’re using and download it. Then, simply follow the installation wizard to install the Arduino IDE.
When you first open the Arduino IDE, you should see something similar to the figure below:
Connecting your Arduino:
Connect your Arduino UNO to your computer via USB.
After connecting your Arduino with a USB cable, you need to make sure that the Arduino IDE has selected the right board.
In our case, we’re using Arduino Uno, so we should go to Tools, Board:
Then, you should select the serial port where your Arduino is connected to. Go to
Tools, Port and select the right port.
Uploading an Arduino Sketch
To show you how to upload code to your Arduino board, we’ll show you a simple example. This is one of the most basic examples – it consists in blinking the on-board LED or digital pin 13 every second.
1. Open your Arduino IDE.
2. Go to File, Examples, 01. Basics, Blink
By default, the Arduino IDE comes pre-configured for the Arduino UNO. Click the Upload button and wait a few seconds.
After a few seconds, you should see a Done uploading message.
This code simply blinks the on-board LED on your Arduino UNO (highlighted with red color). You should see the little LED turn on for one second, and turn off for another second repeatedly.
Control an Output and Read an Input:
An Arduino board contains digital pins, analog pins and PWM pins.
Difference between digital, analog and PWM
In digital pins, you have just two possible states, which are on or off. These can also be referred as High or Low, 1 or 0 and 5V or 0V.
For example, if an LED is on, then, its state is High or 1 or 5V. If it is off, you’ll have Low, or 0 or 0V.
In analog pins, you have unlimited possible states between 0 and 1023. This allows you to read sensor values. For example, with a light sensor, if it is very dark, you’ll read 1023, if it is very bright you’ll read 0 If there is a brightness between dark and very bright you’ll read a value between 0 and 1023.
PWM pins are digital pins, so they output either 0 or 5V. However these pins can output “fake” intermediate voltage values between 0 and 5V, because they can perform “Pulse Width Modulation” (PWM). PWM allows to “simulate” varying levels of power by oscillating the output voltage of the Arduino.
Controlling an output
To control a digital output you use the digitalWrite() function and between brackets you write, the pin you want to control, and then HIGH or LOW.
To control a PWM pin you use the analogWrite() function and between brackets you write the pin you want to control and a number between 0 and 255.
Reading an input
To read an analog input you use the function analogRead() and for a digital input you use digitalRead().
The best way for you to learn Arduino is practising. So, choose a project and start building something.