Arduino

Getting started with Arduino

The Arduino is an advanced form of a microcontroller which is comparatively easier to work on. Similarly, it is a kind of plug and play device and is much easier for the beginners to learn how to make different projects related to embedded systems. Arduino has different types of microcontroller boards having different specifications and the most common Arduino board is the Arduino Uno board. All the Arduino boards can be configured using the Arduino IDE software. This discourse explains how to use the Arduino Uno board

Arduino Uno

The Arduino Uno board comes with a memory of 32 kilobytes and a static RAM of 2 kilobytes. The recommended input voltage at which the board performs well is in the range of 7 to 12 volts. Whereas the operating voltage for the board is 5 volts.

For digital inputs and outputs  there are 14 pins and for the analog inputs and outputs the Arduino uno is provided with 6 pins. This board also has the option of 5 volts and 3.3 volts as the input voltage for small projects like lighting up some LEDs or for the devices which operate at low voltages. There are two pins provided for the serial communication for transmission of data the pin TX is used and for receiving the data the pin RX is used.

The Arduino Uno board has one USB port for interfacing the board with the Arduino software and a port for separate DC power supply is also provided. All the Arduino boards have a reset button that can be used to reset the board to its original settings. The Arduino Uno board is equipped with the Atmel family, that is the Atmega328P.

Arduino Software

To configure the Arduino Uno the software tool used for the Arduino programming is the Arduino IDE which supports two programming languages that is C++. The Arduino program has two main functions : the first function is the setup function and the second function  is the loop function. In the setup function mostly variables, libraries pin modes are initialized, and the loop function runs the program using the initialized functions and variables. The Arduino IDE can be downloaded from the official website of Arduino just click on the link below:

Download the Arduino software by clicking on the option highlighted in the red if you are using windows platform and then install the software by just running the downloaded file. After installing open the Arduino IDE which will be like this:

To program the Arduino Uno the Arduino board  is connected to the computer and this way it is  connected to Arduino software using the USB cable connected to the USB port of the Arduino.

When Arduino Uno is connected there green LED on the Arduino will turn on which means that Arduino is connected further it can be confirmed by the Arduino software. When the Arduino is connected, the connection automatically comes visible at the bottom of the software highlighted in red.

Example

For demonstration purposes a simple sketch for blinking of an LED using Arduino Uno is performed. The components  required for this small project are:

  • Arduino Uno board
  • Jumper wires
  • LED
  • Resistor of 220 Ohms

The diagram for the blinking of the LED project is given as:

The code for Arduino is  explained in detail:

First, in the stepup function the pin at which the led is connected is initialized using the pinMode() function. In this project the LED is connected at pin 10  so pin number will be 10 and it is used as an output device so the mode for the LED will be output.

void setup(){
 pinMode(10, OUTPUT);
}

Coming to the loop function to make LED blink we have given it both states that are HIGH and LOW. To assign the states we have used the digitalWrite() function. since we have connected the LED to the pin 10 so the first argument is the pin number and the second argument is state of LED that is HIGH:

digitalWrite(10, HIGH);

Then we have given a delay of 5 milliseconds so the LED will remain at high state for 5 milliseconds:

delay(500);

After that we have again used the digitalWrite() function to give LED a LOW state:

digitalWrite(10, LOW);

To  keep the LED off for some 5 milliseconds a  delay of 5 milliseconds is given:

delay(500);

Here is the completer Arduino code for blinking the LED:

void setup(){
pinMode(10, OUTPUT);
}
void loop() {
  digitalWrite(10, HIGH);  
  delay(500);              
  digitalWrite(10, LOW);  
  delay(500);            
}

After writing the code first click on the blue tick icon on the top left corner to verify and compile the code. The   compilation status  will be shown  in the output window at the bottom.

After the program is compiled it is then uploaded to the Arduino board by clicking to the next icon to the tick icon. The successful status of  uploading will be displayed at the bottom in the output menu.

Output

Conclusion

The Arduino boards are used to program the microcontrollers and to make the use of microcontrollers much easier. These boards are also helpful for the beginners to learn about the circuit design and their implementation. Similarly, these boards make the interfacing of different devices with microcontrollers easy. In this write up how to program an  Arduino uno is illustrated with a demonstration of a simple project.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.