how to write arduino code, arduino code, arduino coding, arduino code writing
Hello everyone, I hope you all are fine and having fun with your lives. In today's post, I am going to share all about Arduino Data Types. Arduino Data Types play an important role in Arduino Programming and I have discussed them a little in my tutorial on How to do Arduino Programming. But today, we are gonna discuss it in more detail. I hope you guys are gonna enjoy from them and are gonna get benefit using them. Before going any further I think you must have a llok at Arduino Basic Tutorials in which I have explained everything in a very easy way. Anyways, Till now I hopeo that you have the basic know how of Arduino Programming and you ahave also worked on Arduino LED Example. So, let's get started with Arduino Data Types:

What are Data Types ??

  • If you recall your basic mathematics in which we have learned about sets like Whole Numbers, Natural Number, Prime Numbers etc.
  • So, in simple words, Data Types are such sets, but Data Types are different on the nature of element storing in them.
  • Data type is like a place, so when we initialize our variale then we tell our compiler that our newly introduced integer is of which type.
  • Is it an integer or it has decimal as well in it or its some character like A, B, C etc.
  • So, we have to tell our compiler the nature of our variable and that's where Data Types are required.
  • So, that's a little Introduction of Data Types, now let's have a look at Arduino Data Types:

Arduino Data Types

  • Arduino Data Types are almost similar to C++ Data Types because it roughly follows the same syntax.
  • So, now I am gonna discuss the most commonly used Arduino Data Types one by one:
Int - Arduino Data Types
  • Int is short form for Integer.
  • This Arduino Data Types can store a data of 16 Bit.
  • Int data ranges from -32,768 to 32767.
  • In Arduino Programmer, Int variable in initialized in several ways, which are:

int Value = 0;

int Value;

int Value1, Value2, Value3;

Char - Arduino Data Types
  • char is short for character.
  • This Arduino Data Type has a memory of 8 Bit or 1 byte.
  • Char Data Type saves charracters like A, B, C etc.
  • If you are initializing a single character then it will be in single quotes like 'A'.
  • But if you are dealing with character Array then it must be enclosed in doule brackets like this "ABCD".
  • When we save any character then in actual the ascii code of that character is being saved.
  • For example if you save a character '1', then its not integer 1 it is a character '1' and its ascii value is 49.
  • So, in that variable the value saved is 49.
  • All the Serial Communication is done using this char Data Type.
  • You should read How to do Arduino Serial Communication in which I have used this char variable.
Boolean - Arduino Data Types
  • Boolean data type is also used quite a lot in Arduino Programming.
  • Boolean is also of 8 Bit just like char and it can be either True or False, that's why we call it Boolean.
  • So, we can initialize a Boolean variable as:

boolean a;

Float - Arduino Data Types
  • Float is another very important Arduino Data type.
  • The unique thing of Float Data Type is that we can store decimal numbers in it.
  • For example I want to save 2.51 then I have to use Float because this value can't be save in Int or Char.
The above mentioned Arduino Data Types are the most commonly used data types and I hope you got their details in today's tutorial. In the below figure, I have mentioned all details about Arduino Data Types:
how to write arduino code, arduino code, arduino coding, arduino code writing
So, that's all about Arduino Data Types. In the coming tutorial I will share more about Arduino. So, take care and have fun !!! :)