The Only Beginner Friendly Guide to Arduino — Part 1

Hey Beginner! Welcome to the first part of the Beginner Friendly Guide to the Arduino. Before you venture on, I must warn you, the Arduino is a world in itself. It contains a plethora of resources online. Most of the resources I feel are misleading and do not focus on the issue at hand — what the beginner actually needs. This article will give you just that and not more than what you can chew.

DISCLAIMER: The following text contains only what is required by a beginner and does not cater to the intricate technicalities of the microcontroller itself. We will be using the Arduino Uno throughout our journey.

Ingredients Required

For this tutorial, you will be needing just an Arduino board, which you can buy here.

This is how your board looks like!

The Prequel — What should you know before?
1. What is an Arduino board?
An Arduino board is a microcontroller. A microcontroller is a small computer with memory. What is in your laptop is just a bigger, complex version of the same. The Arduino is a mere trailer to it. It provides ways for the developer ie; you to program it and do your bidding. If you are a sucker for documentations, here you go!

2. What do I need to program it?
There is an IDE on the Arduino website. You can download it from this link. The acts as the compiler, assembler, and burner, by uploading the program into the memory. Voila! Now you have programmed it!

3. How do I code man?
To be honest, microcontroller programming ain’t that difficult. Download the Arduino book from here if you need a lot of commands in your repertoire. Honestly, you don’t need so much, I will be giving the commands you absolutely need for your first project here-


1. pinMode(pin number,input/output)
2. DigitalWrite(pin number, Digital Output)

That’s it.

4. What are the total number of programmable inout pins?
This thing contains 14 digital inout pins and 6 analog input pins, a power jack, and more. This is all we need to know right now. Bombarding ourselves with extra information at this stage will not take us anywhere.

Time to get our hands dirty — the first code!
The first code we will be starting with is the most obvious, often overlooked for its simplicity but underrated for its powerfulness — Getting an LED to blink!

Image for representation purposes only. Source: https://makeabilitylab.github.io/physcomp/arduino/assets/movies/Arduino_LEDBlink_Pin3.gif

Why do I feel it is powerful?
The world’s best device is a switch. If we see all devices come under two things — switches or memory. Blinking an LED is essentially powering it up and cutting off power to it. We are programming the microcontroller to act as a switch. If the fundamentals are strong, future projects will not crumble.

The CODE!



void setup() {
// put your setup code here, to run once:
pinMode(13,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:

digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
delay(1000);
}

I know you want to know what these mean!

The first block of code called setup (highlighted below) configures the controller to suit your need. Whatever code that goes in here, will be executed before the original intent of the program — the need is executed. For example, in a washing machine, we first set the water level, rinse times, and spin times before the machine starts its work. This is similar to that.

In this block, we configure pin 13 as the output pin. Since it is a digital I/O, we use the command DigitalWrite(13, OUTPUT).

void setup() {
// put your setup code here, to run once:
pinMode(13,OUTPUT);
}

The second block of code called loop does the main job. All the code that goes in here is repeated infinitely. To get an LED to blink, we switch it on for while then switch it off again. This is what the following piece of code does -
Here when we write the value “HIGH” (1) to the pin, it means that the LED will turn on and give out light.

digitalWrite(13,HIGH);
delay(1000);

The delay statement gives the time between on/off. The argument 1000 equals 1ms.
Consequently, we write “LOW” to the same pin, turning off the LED. The delay statement waits for 1ms before switching on the LED again.

digitalWrite(13,LOW);
delay(1000);

Now the most important part! BURNING the code into the controller!
Connect the Arduino Uno to your PC/laptop. The USB cable (2.0, A/B type) comes with the kit.

Source: https://www.getready.io/arduino

First, compile the code. Click the tick mark on the top panel. The outcome of the compilation will be reflected in the black window below the editor. If it is compiling clean, click on the right arrow to burn the code. We are now done!

Why do we need the delay statement?
There are 16 million clocks per second in the Uno. If we do not provide any delay in between, we will not see the blinks. They will happen rapidly, 16000x the maximum frames per second the human eye can process. Hence, we need to add delays in between to process what is happening in front of us.

Do I need to configure the 13th pin only when there are so many others?
The 13th pin is directly connected to the in-built LED of the controller. This is hassle-free. Imagine using a resistor, a breadboard, few wires all connected to the controller!

I hope you enjoyed the tutorial. I am Vijayalakshmi, currently an ASIC Digital and Verification Engineer at Synopsys. You can connect with me here. Hoping to see you soon in the next guide. Until then!

I read, learn and create! Always up for engaging conversations about anything! Do connect with me on https://www.linkedin.com/in/vijayalakshmiswaminathan/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store