Arduino Tutorials:Using variables in arduino IDE

Published by sandesh on

Variables in arduino:

Variable is the method through which we can store data(or values). This is so important in any programming language. For example, if someone want to call you they will with the help of your name. In the same way we call some values with the help of its name (variables) whenever and wherever we want.

There are many types of variables, includes:

Char: A char is a data type used to store single character values.when you declare a char, it should be written in between ‘ ’. The size of the char is 8 bits.

Example: char var_name = ‘a’

Here, var_name is variable’s name and ‘a’ is the value stored in var_name

Byte: A byte is a data type used to store 8-bit unsigned number, from 0 to 255.

Example: byte var_name = 23

Here, var_name is variable’s name and 23 is the value stored in var_name


Int : An int is a data type used to store integer values. The size of the int is 32-bits(4bytes).You can declare an integer in between -32,768 to 32,767

Example: Int var_name = 2563

Here, var_name is variable’s name and 2563 is the value stored in var_name

Unsigned int : An unsigned int is a data type used to store unsigned integer values. The size of the unsigned int is 16-bits(2bytes).You can declare an integer in between 0 to 65,535

Example: unsigned int var_name = 2189

Here, var_name is variable’s name and 2189 is the value stored in var_name


Long : A long is a data type used to store integer values. The size of the long is 32-bits(4bytes).You can declare an integer in between -2,147,483,648 to 2,147,483,647 (-2^31 to 2^31 -1).

Example: long var_name = 2563

Here, var_name is variable’s name and 2563 is the value stored in var_name

Unsigned long : An unsigned long is a data type used to store unsigned integer values. The size of the char is 16-bits(2bytes).You can declare an integer in between 0 to 4,294,967,295 (2^32 -1)

Example: unsigned int var_name = 0

Here, var_name is variable’s name and 0 is the value stored in var_name

Float : A float is a data type used to store floating-point numbers.when you declare a float, it should be in between 3.4028235E+38 and -3.4028235E+38. The size of the float is 32 bits.

Example: float var_name = 87.63

Here, var_name is variable’s name and 87.63 is the value stored in var_name


Double : A double is a data type used to store floating-point numbers. The size of the float is 64 bits.

Example: double var_name = 49.865

Here, var_name is variable’s name and 49.865 is the value stored in var_name


String : A string is a data type used to store multiple character values.when you declare a string, it should be written in between “ ”.

Example: string var_name = “hello”

Here, var_name is variable’s name and “hello” I the value stored in var_name

Next Post:Functions and Libraries in Arduino IDE

Previous Post:Various Types of Memories in Arduino


1 Comment

Arduino Tutorials:Functions and Libraries in Arduino IDE - projectsflix · January 3, 2021 at 5:28 pm

[…] Previous Post:Using variables in arduino IDE […]

Leave a Reply

Avatar placeholder

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.