Arduino Basics | Arduino quick explanation


Here is a quick explanation of all the standard instructions supported by the Arduino language.


An Arduino sketch runs in two parts:

void setup()

This is where you set things up that have to be done once before the loop starts running, and then don’t need to happen again.

void loop()

This contains the main code of your sketch. It contains a set of instructions that get repeated over and over until the board is switched oˆff.

Special Symbols

Arduino includes a number of symbols to delineate lines of code, comments, and blocks of code.

; (semicolon)

Every instruction (line of code) is terminated by a semicolon. This syntax lets you format the code freely. You could even put two instructions on the same line, as long as you seperate them with a semicolon. (However, this would make the code harder to read.)



{} (curly braces)

These are used to mark blocks of code. For example, when you write code for the loop() function, you have to use a
curly brace before and after the code.

Related  How to connect Arduino IDE To Ardublockly In Windows easy Method


void loop() {


These are portions of text ignored by the Arduino microcontroller, but are extremely useful to explain to others (and to remind yourself) what a piece of code does.
There are two styles of comments in Arduino:

// single-line: 
/* multiple-line:
 you can write
 multiple line


Arduino includes a set of predefined keywords with special values .HIGH and LOW are used, for example, when you want to turn on or oˆ an Arduino pin. INPUT and OUTPUT are used to set a specific pin to be either an input or an output. true and false are used to test whether a condition or expression is true or false. They are used primarily with comparison operators.


Variables are named areas of the Arduino’s memory where you can store data. Your sketch can use and manipulate this data by referring to it by the variable name. As the word variable suggests, variables can be changed as many times as you like.

Because Arduino is a very simple micro controller, when you declare a variable, you have to specify its type. This means telling the micro controller the size of the value you want to store.

Related  Turn on LED when the button is pressed and keep it on after it is released arduino

Following are the data types that are available.


can have one of two values: true or false.


Holds a single character, such as the letter A. Like any computer, Arduino stores it as a number, even though you see text. When chars are used to store numbers, they can hold values from –128 to 127. A char occupies 1 byte of memory.


Holds a number between 0 and 255. Like a char, a byte uses only 1 byte of memory. Unlike chars, a byte can store only positive numbers.


Uses 2 bytes of memory to represent a number between –32,768 and 32,767. The int is the most common datatype used in Arduino. If you are unsure of what datatype to use,try an int.

unsigned int

Like int, uses 2 bytes of memory, but the unsigned prefix means that it can’t store negative numbers, so its range goes from 0 to 65,535.


This is twice the size of an int and holds numbers from –2,147,483,648 to 2,147,483,647

unsigned long

Unsigned version of long; it goes from 0 to 4,294,967,295.


This is quite big and can hold floating-point values, which is a fancy way of saying that you can use a float to store numbers with a decimal point. A float will eat up 4 bytes of your precious RAM, and the functions that can handle them use up a lot of code memory as well, so use floats only when you need to.

Related  Difference between Arduino uno and Leonardo


Double-precision floating-point number, with a maximum value of 1.7976931348623157 \times 10^{308}.


A set of ASCII characters used to store textual information(you might use a string to send a message via a serial port,
or to display on an LCD display). For storage, they use 1 byte for each character in the string, plus a null character (1 byte) at the end to tell Arduino that it’s the end of the string. The following are equivalent:

char string1[] = "Arduino"; // 7 chars + 1 null char
char string2[8] = "Arduino"; // Same as above


A list of variables that can be accessed via an index. They are used to build tables of values that can easily be accessed.
For example, if you want to store different levels of brightness to be used when fading an LED, you could create six variables called light01, light02, and so on. Better yet, you could use a simple array like this

int light[6] = {10, 20, 30, 40, 50, 60, 70, 80};


Leave a Reply

Your email address will not be published. Required fields are marked *

Top 5 Most Expensive Domains Ever Sold 4 Must-Try ChatGPT Alternatives: Perplexity AI, BardAI, Pi, and More! Types of Trading Techniques in the Stock Market. ChatGPT app now available in India this AI chatbot can help you make your life more productive. What is wrong with following function code?