@@ -10,35 +10,15 @@ The Arduino_SensorKit Library can be downloaded from the Arduino IDE’s library
10
10
11
11
# Classes
12
12
13
- ## SensorKit class
14
-
15
- ### Declaration
13
+ ## Including the library
16
14
17
15
``` cpp
18
16
#include " Arduino_SensorKit.h"
19
17
20
- SensorKit kit; // Declare the object to use it later
21
-
22
18
void setup (){}
23
19
void loop (){}
24
20
```
25
21
26
- ### Initialization
27
-
28
- Using the function ` begin() ` at the beginning of the ` setup() `
29
-
30
- ``` cpp
31
- #include " Arduino_SensorKit.h"
32
-
33
- SensorKit kit; // Declare the object to use it later
34
-
35
- void setup (){
36
- kit.begin();
37
- }
38
-
39
- void loop(){}
40
- ```
41
-
42
22
## OLED
43
23
Using the Grove - OLED Display 0.96 inch
44
24
@@ -47,37 +27,33 @@ Using the Grove - OLED Display 0.96 inch
47
27
Init and returns true if success, already done in the ` SensorKit ` 's object ` begin() `
48
28
49
29
``` cpp
50
- if(!Oled.begin()){
51
- Serial.println("Error");
52
- while(1);
53
- }
54
- Serial.println("Ok");
30
+ void setup (){
31
+ Oled.begin();
32
+ }
33
+ void loop(){}
55
34
```
56
35
### Printing "hello world"
57
36
58
37
```cpp
59
38
#include "Arduino_SensorKit.h"
60
39
61
- SensorKit kit;
62
-
63
40
void setup() {
64
- kit.begin();
41
+ Oled.begin();
42
+ Oled.setFlipMode(1); //Rotate it
65
43
}
66
44
67
45
void loop() {
68
- Oled.clearBuffer(); // clear the internal memory
69
- Oled.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
70
- Oled.setCursor(0, 10);
71
- Oled.print("Hello World"); // write something to the internal memory
72
- Oled.sendBuffer(); // transfer internal memory to the display
46
+ Oled.setFont(u8x8_font_chroma48medium8_r);
47
+ Oled.drawString(0,0,"Hello World!");
48
+ Oled.refreshDisplay(); // only required for SSD1606/7
73
49
delay(1000);
74
50
}
75
51
```
76
52
77
53
### Printing values
78
54
79
55
``` cpp
80
- Oled.print(value);
56
+ Oled.print(value);
81
57
```
82
58
83
59
## Accelerometer
@@ -88,24 +64,21 @@ Using the Grove - 3-Axis Digital Accelerometer (±1.5g)
88
64
Init and returns true if success, already done in the ` SensorKit ` 's object ` begin() `
89
65
90
66
``` cpp
91
- if (!Accelerometer.begin()){
92
- Serial.println("Error"); // Accelerometer didnt initialized
93
- while(1); // Stop the program
67
+ void setup (){
68
+ Accelerometer.begin();
94
69
}
95
- Serial.println("Init complete");
70
+ void loop(){}
96
71
```
97
72
98
73
### Reading the Acceleration X
99
74
100
75
```cpp
101
76
#include "Arduino_SensorKit.h"
102
-
103
- SensorKit kit; //Declare the object to use it later
104
-
77
+
105
78
float acceleration;
106
79
107
80
void setup(){
108
- kit .begin();
81
+ Accelerometer .begin();
109
82
}
110
83
111
84
void loop(){
@@ -119,13 +92,12 @@ Init and returns true if success, already done in the `SensorKit`'s object `begi
119
92
120
93
``` cpp
121
94
#include " Arduino_SensorKit.h"
122
- SensorKit kit;
123
95
124
96
float x,y,z; // Values for the readings
125
97
126
98
setup (){
127
99
Serial.begin(9600);
128
- kit .begin();
100
+ Accelerometer .begin();
129
101
}
130
102
131
103
loop{
@@ -145,13 +117,12 @@ Return if the sensor its good to give the data
145
117
146
118
```cpp
147
119
#include "Arduino_SensorKit.h"
148
- SensorKit kit;
149
120
150
121
float x,y,z; // Values for the readings
151
122
152
123
setup(){
153
124
Serial.begin(9600);
154
- kit .begin();
125
+ Accelerometer .begin();
155
126
}
156
127
157
128
loop{
@@ -169,24 +140,22 @@ The Pressure sensor can get temperature, pressure and altitude
169
140
### Initialising the sensor
170
141
Init and returns true if success, already done in the ` SensorKit ` 's object ` begin() `
171
142
``` cpp
172
- if (!Pressure.begin()){
173
- Serial.println("Error"); // Accelerometer didnt initialized
174
- while(1); // Stop the program
143
+ void setup (){
144
+ Pressure.begin();
175
145
}
176
- Serial.println("Init complete");
146
+ void loop(){}
177
147
```
178
148
179
149
### Reading the Temperature values
180
150
181
151
```cpp
182
152
#include "Arduino_SensorKit.h"
183
- SensorKit kit;
184
153
185
154
float temperature; // Value for the reading
186
155
187
156
setup(){
188
157
Serial.begin(9600);
189
- kit .begin();
158
+ Pressure .begin();
190
159
}
191
160
192
161
loop{
@@ -200,13 +169,12 @@ Init and returns true if success, already done in the `SensorKit`'s object `begi
200
169
201
170
``` cpp
202
171
#include " Arduino_SensorKit.h"
203
- SensorKit kit;
204
172
205
173
uint32_t pressure; // Value for the reading
206
174
207
175
setup (){
208
176
Serial.begin(9600);
209
- kit .begin();
177
+ Pressure .begin();
210
178
}
211
179
212
180
loop{
@@ -219,13 +187,12 @@ Init and returns true if success, already done in the `SensorKit`'s object `begi
219
187
### Reading the Altitude values
220
188
```cpp
221
189
#include "Arduino_SensorKit.h"
222
- SensorKit kit;
223
190
224
191
float altitude; // Value for the reading
225
192
226
193
setup(){
227
194
Serial.begin(9600);
228
- kit .begin();
195
+ Presure .begin();
229
196
}
230
197
231
198
loop{
@@ -247,24 +214,22 @@ By default, once you include the library it has been set to digital pin `3`, it
247
214
248
215
### Initialising the sensor
249
216
```cpp
250
- if (!Environment.begin()){
251
- Serial.println("Error"); // Accelerometer didnt initialized
252
- while(1); // Stop the program
217
+ void setup(){
218
+ Environment.begin();
253
219
}
254
- Serial.println("Init complete");
220
+ void loop(){}
255
221
```
256
222
257
223
### Reading the Temperature values
258
224
259
225
```cpp
260
226
#include " Arduino_SensorKit.h"
261
- SensorKit kit;
262
227
263
228
float temperature;
264
229
265
230
void setup () {
266
231
Serial.begin(9600);
267
- kit .begin();
232
+ Environment .begin();
268
233
}
269
234
270
235
void loop() {
@@ -279,7 +244,6 @@ By default, once you include the library it has been set to digital pin `3`, it
279
244
280
245
```cpp
281
246
#include "Arduino_SensorKit.h"
282
- SensorKit kit;
283
247
284
248
float humidity;
285
249
0 commit comments