Data types in Arduino

Hello friends, Welcome back to my blog. We have described the previous articles as practical projects. But today’s article is theoretically. We have learned a piece of basic knowledge about Arduino from previous articles. Today we are going to talk about something that is most important for Arduino coding. It is Data types or variables. Do you remember we have used variables in the previous posts? Okay, today we’re going to talk about data types.



What are Data types?

    When we write codes, the data contained in them must be provided separately to the Arduino compiler. These data are called Data types. Arduino compiler is a program that translates the code we write into machine language so that it can be understood by the microcontroller. Machine language is a language that uses only 0 and 1. We do not understand this language. The code we write using the English language is translated into code 0 and 1 by the compiler.
Ex: – 010001010101001
These codes are called binary codes. This process also occurs in other high-level languages. All data and programs in this microcontroller use this binary language. These binary codes have installed the register in the microcontroller.

What is the register?

    A register is a part that installs a binary code. It is the hardware of the microcontroller. The registers have different bit sizes. Take a look at the 8-bit register below.
7    |    6    |    5    |    4    |    3    |    2    |    1    |    0
0    |    0    |     1   |      0  |    1    |    1    |    0    |    0
The 8-bit register is 0-7. It can put eight values ​​containing 0 or 1. The Arduino Uno board has an 8-bit register. This is not common for all microcontrollers. There are microcontrollers on the market that contain registers with different bits. The microcontroller includes two types of registers. That is a volatile memory register and a nonvolatile memory register. These data types are stored in volatile memory. The data in this memory is lost due to a power-off. When writing this code we have to work with different data types. Different names are used to identify these data types separately. These data types must be named before the code can be written. This is called a variable declaring. Okay, let’s look at the data types we use the most.




boolean

 It can be set to ‘true or false’, ‘high or low’, and ‘0 or 1’. 

This data type takes up 1 byte of memory.

byte

We can use this data type if we want to store a value from 0-255. This datatype memory is 1 byte.

char

This data type can only store characters. It is a number, a letter, or a symbol. It is a 1-byte memory.

double

We can use this datatype for decimals numbers. This datatype memory is a 4 byte.

int

This data type is the most used. Its data range is -32 768 to +32 767. This datatype memory is a 2 byte.

long

This data type can be used for long data stored. Its range is a -2 147 483 648 to +2 147 483 647. The Memory is a 4 byte.

string

Words can be stored in this data type. For example “sritu tech”.

void

This data type is used for function definitions.




So, today we have learned many data types that use in Arduino coding. These data types are included in other programming languages ​​as well. The Arduino language is created using high-level languages ​​C and C ++. I hope you have learned about data types through this post. We will meet in the next post. Have a good day. Bye-bye.

Similar Posts

Leave a Reply

Your email address will not be published.