Difference between revisions of "Mixly Block Category - Variables"
Line 1: | Line 1: | ||
− | A variable is a place to store a piece of data. It has a name, a value, and a type. | + | A variable is a place to store a piece of data. It has a name, a value, and a type. To access the variable simple use the variable name. |
*Name - The name or label of that specific variable. Variables are named instances of a Data Type. | *Name - The name or label of that specific variable. Variables are named instances of a Data Type. | ||
*Data Type - There are different data types. Such as integers, floats & doubles (decimals), boolean (true or false), and custom ones. Variables are an instance of a data type. | *Data Type - There are different data types. Such as integers, floats & doubles (decimals), boolean (true or false), and custom ones. Variables are an instance of a data type. | ||
*Value - Is the stored value of of the Data Type which is referenced under the Variable Name. | *Value - Is the stored value of of the Data Type which is referenced under the Variable Name. | ||
+ | |||
In code the format is usually in this format: | In code the format is usually in this format: | ||
'''Data_Type Variable_Name = Value;''' | '''Data_Type Variable_Name = Value;''' | ||
+ | |||
Example: | Example: | ||
− | + | '''int some_variable_name = 5;''' | |
*Data Type = int | *Data Type = int | ||
*Name = some_variable | *Name = some_variable | ||
*Value = 5 | *Value = 5 | ||
+ | This means there is a variable that is named '''some_variable''' of Data Type '''int''' that contains the value '''5'''. | ||
+ | |||
+ | |||
Read more here: https://www.arduino.cc/en/Tutorial/Variables | Read more here: https://www.arduino.cc/en/Tutorial/Variables | ||
=Declare Variable= | =Declare Variable= | ||
+ | A variable is a way of naming and storing a value for later use by the program, such as data from a sensor or an intermediate value used in a calculation. | ||
+ | |||
+ | Read more here (: https://www.arduino.cc/en/Reference/VariableDeclaration | ||
=After Declaring a Variable= | =After Declaring a Variable= | ||
− | ==Assign | + | After declaring a variable enables new blocks for that variable. |
− | ==Access | + | ==Assign Value== |
+ | Assigns a value to the variable that was declared. | ||
+ | *Value - Stores this into the variable. Should be of the same Data Type or problems may occur. | ||
+ | |||
+ | |||
+ | Read more here: https://www.arduino.cc/en/Tutorial/Variables | ||
+ | ==Access Value== | ||
+ | Returns the value stored in the variable. The return will be of the Data Type the variable is. | ||
+ | |||
+ | |||
+ | Read more here: https://www.arduino.cc/en/Tutorial/Variables |
Latest revision as of 23:05, 27 February 2017
A variable is a place to store a piece of data. It has a name, a value, and a type. To access the variable simple use the variable name.
- Name - The name or label of that specific variable. Variables are named instances of a Data Type.
- Data Type - There are different data types. Such as integers, floats & doubles (decimals), boolean (true or false), and custom ones. Variables are an instance of a data type.
- Value - Is the stored value of of the Data Type which is referenced under the Variable Name.
In code the format is usually in this format:
Data_Type Variable_Name = Value;
Example:
int some_variable_name = 5;
- Data Type = int
- Name = some_variable
- Value = 5
This means there is a variable that is named some_variable of Data Type int that contains the value 5.
Read more here: https://www.arduino.cc/en/Tutorial/Variables
Declare Variable
A variable is a way of naming and storing a value for later use by the program, such as data from a sensor or an intermediate value used in a calculation.
Read more here (: https://www.arduino.cc/en/Reference/VariableDeclaration
After Declaring a Variable
After declaring a variable enables new blocks for that variable.
Assign Value
Assigns a value to the variable that was declared.
- Value - Stores this into the variable. Should be of the same Data Type or problems may occur.
Read more here: https://www.arduino.cc/en/Tutorial/Variables
Access Value
Returns the value stored in the variable. The return will be of the Data Type the variable is.
Read more here: https://www.arduino.cc/en/Tutorial/Variables