Arduino is open source hardware platform which allows to control devices using simple easy to understand programs. The interface is so simple that anyone with little knowledge of electronics and programming can easily connect sensors, motors, servos to create programmable devices.
The hardware is actually a micro controller sitting on a prototyping board with inbuilt power supply, USB interface to connect to modern computers and bunch of input output pins to connect the other devices. The micro controller is low cost, low power 8 bit Atmega328p chip from Atmel corporation. The datasheet for the micro controller can be found here.
There are many version of the device available, the entry level module Arduino UNO is very popular (Below). It has all the components (USB, Power Supply Unit, Micro Chip) integrated on a single board.
The original device can be brought from various online stores. There are many clones available in the market. All of them work pretty similar. Most of the time the device shipped from manufacturers have boot loader burnt into them. Boot loader is a program which makes this device programmable, i.e. You can burn your own code on top of it and it will execute your code as soon as you power it.
The heart of the Arudino is its IDE (Integrated Development Environment). Which is a java based console with 100s of easy to use library, well documented online guides, millions of helpful communities and users. It makes Arduino a breeze.
Setting up the IDE
You can follow the guide available on Arduino website to install the IDE and USB driver. The IDE looks like below screenshot. It is a typical GUI environment with multiple menus and console to write code.
Once the device is plugged using USB it shown as COM device in the windows device manager (image below). This is basically a virtual com port, i.e. Physically the device is connected using USB, but the computer sees this as COM device. There is no magic, the UNO board has USB to serial converter chip (shown in the image above), which takes care of USB to serial conversion. The Driver software loaded while running setup helps the chip to communicate with the PC using USB interface. Sometimes, Driver software is not installed automatically and you have to find the driver for the chip used in the UNO board and install it manually.
Running the first Example (Blink)
Step 1: Select the device
After plugging the board and opening the IDE, we have to select the port. Port is channel which the IDE and the device would communicate. In my case it is COM7 as seen in device manager. Most of the times it appears automatically in the port menu. This can be anything from COM0 to COMXX where XX is a number. Select this in your setup.
Step 2: Select the board
Arduino comes in many versions. We have to select the board we are using. In my case “Arduino UNO” is used. So, I selected Tools -> Boards -> Ardunio/Genuino UNO.
Step 3 : Select an example ( Blink )
The IDE has 100s of inbuilt examples, the easiest of these are Blink. The code blinks inbuilt LED. A typical Arduino example has two parts in code, function setup() and the function loop().
The setup function runs once when reset button is pressed or the board is powered on. This is used to initialize all the variables, pin, objects to be used in the subsequent code.
The loop function runs continuously till the board is powered on. It does an operation in loop and repeat itself. Below is the blink example, its self explanatory. Further you can look at Arduino website here . to understand more about the blink example.
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Step 4: Upload the Code
Once the code is written/copied in the IDE console. You can hit Switch -> Upload ( ctrl + u) to load the code from console to the Arduino board. The bottom of the IDE would show “Done uploading”. Now the Blink example in loaded into the Board.
Time to Blink 🙂
Once the code is uploaded to the board, it starts working. The image below shows the blinking inbuilt LED.
There are many examples and projects which can be done using Arduino as a micro controller. Keep exploring and ask questions if you have any.