-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyword.json
208 lines (198 loc) · 7.78 KB
/
keyword.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
{
"keywords": [
{
"class": "library-keyword",
"title": "Libraries",
"contents": [
{
"type": "text",
"content": "A library is a file that contains pre-written code. By adding <span class='inline-code'>#include “name_of_function_library.h”</span> at the top of your code, you can use objects and call functions in the library as if they existed within your code."
}
]
},
{
"class": "function-keyword",
"title": "Functions",
"contents": [
{
"type": "text",
"content": "A function is a “self-contained” module of code that will only run when it is specifically called. Functions usually “take in” data, process it, and “return” a result."
},
{
"type": "text",
"content": "A function is composed of two parts: a declaration and a definition:"
},
{
"type": "code-block",
"content": "void myFunction() { // declaration \n\t// code to be executed (definition) \n}"
},
{
"type": "text",
"content": "Once a function has been declared, you must call it whenever you want the code written inside the definition to run:"
},
{
"type": "code-block",
"content": "myFunction(); // call the function"
},
{
"type": "text",
"content": "Once a function has been written once, it can be called over and over again."
}
]
},
{
"class": "functionParameters-keyword",
"title": "Function Parameters",
"contents": [
{
"type": "text",
"content": "Information can be passed to functions as input however we must first specify the types and quantity of input that the function is expecting. Each of these inputs is called a parameter. Parameters act as variables inside of the function."
},
{
"type": "text",
"content": "Parameters are specified after the function name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma:"
},
{
"type": "code-block",
"content": "void functionName(parameter1, parameter2, parameter3) { \n\t// code to be executed\n}"
}
]
},
{
"class": "variables-keyword",
"title": "Variables",
"contents": [
{
"type": "text",
"content": "Variables are “containers” that store data values. Each variable can only store data of a specific type. Data types that we will be using are <span class='inline-code'>float</span> (short for floating decimal), <span class='inline-code'>int</span> (short for integer) and <span class='inline-code'>bool</span> (short for boolean)."
},
{
"type": "text",
"content": "You declare a variable by specifying its type, then name, then assigning it a value, like so:"
},
{
"type": "code-block",
"content": "type variable_name = value;"
}
]
},
{
"class": "float-keyword",
"title": "float",
"contents": [
{
"type": "text",
"content": "<span class='inline-code'>float</span> is short for floating-point number. A floating-point number is a number that has a decimal point."
},
{
"type": "text",
"content": "They are often used to approximate analog and continuous values because they have a greater resolution than integers."
},
{
"type": "text",
"content": "Examples of floating-point numbers: <br><span class='inline-code'>34.567</span> <br><span class='inline-code'>2.0</span> <br><span class='inline-code'>0.01</span>"
}
]
},
{
"class": "int-keyword",
"title": "int",
"contents": [
{
"type": "text",
"content": "<span class='inline-code'>int</span> is short for integer. Integers are whole numbers (so they do not have any decimal points)."
},
{
"type": "text",
"content": "Integers are our primary data type for number storage."
},
{
"type": "text",
"content": "Examples of floating-point numbers: <br><span class='inline-code'>35</span> <br><span class='inline-code'>2</span> <br><span class='inline-code'>0</span>"
}
]
},
{
"class": "bool-keyword",
"title": "bool",
"contents": [
{
"type": "text",
"content": "<span class='inline-code'>bool</span> is short for boolean. A boolean only has one of two possible values: <span class='inline-code'>true</span> or <span class='inline-code'>false</span>."
},
{
"type": "text",
"content": "Booleans are useful if we want to check if a condition has been met (true) or has not (false) and store this result."
}
]
},
{
"class": "array-keyword",
"title": "Array",
"contents": [
{
"type": "text",
"content": "An array is a collection of variables of the same data type that are accessed with an index number."
},
{
"type": "text",
"content": "An index number is a way to refer to each of the individual elements in the array. Index numbers start at 0. This means that the first item in the array will have an index of 0, the second item in the array will have an index of 1, the third will have an index of 2 and so on."
},
{
"type": "text",
"content": "When creating an array, you must also declare the data types of the values stored in the array. In the example below, we create an array called <span class='inline-code'>arrayValues</span> that contains five integers."
},
{
"type": "code-block",
"content": "int arrayValues[] = {2, 4, -8, 3, 2};"
}
]
},
{
"class": "sensor-keyword",
"title": "Sensor",
"contents": [
{
"type": "text",
"content": "Sensors take input from their environment and send information to our code."
},
{
"type": "text",
"content": "Examples: <br>Thermometers measure temperature <br>Microphones measure sounds <br>IR sensors measure and detect infrared radiation"
}
]
},
{
"class": "actuator-keyword",
"title": "Actuator",
"contents": [
{
"type": "text",
"content": "Actuators take input from our code and create an output in their environment."
},
{
"type": "text",
"content": "Examples: <br><br><b>Servo motors</b> create a circular movement <br> <b>Hydraulic cylinders</b> create linear movement <br> <b>Speakers</b> create sound <br> <b>Heaters/coolers</b> create temperature changes"
}
]
},
{
"class": "classAndObject-keyword",
"title": "Classes and Objects",
"contents": [
{
"type": "text",
"content": "Classes are the building blocks of Arduino code. They are types of data that include their own specific predefined variables and functions. An object is a specific instance of a class."
},
{
"type": "text",
"content": "A car is a real-world example of a class. Each car has a set of variables (weight, colour, top speed) and a set of functions (drive, brake, turn)."
},
{
"type": "text",
"content": "If a car is a class, then each specific model of car is an object. Each model is built from the same car class, i.e. they share the same variables and functions, however the values of those variables and the specific outputs of those functions will be different for each model."
}
]
}
]
}