ARGB Sample
This application demonstrates reading ambient light and RGB light values from the sensor.
To run the example:
  1. 1.
    Open the IoT_Node_ALSGesture_ARGB sketch from the examples menu.
  2. 2.
    Select Turta IoT Node from the Tools > Board menu.
  3. 3.
    Select your device's COM port from Tools > Port menu.
  4. 4.
    Open Serial Monitor from Tools > Serial Monitor.
  5. 5.
    Select 115.200 baud from the Serial Monitor's status bar.
  6. 6.
    Upload the code to your device.

Sample Code

IoT_Node_ALSGesture_ARGB.ino
1
#include <Turta_ALSGesture_Module.h>
2
3
// Create ALS Gesture Sensor instance.
4
Turta_ALSGesture_Module als;
5
6
void setup() {
7
// Initialize ALS Gesture Sensor.
8
als.begin();
9
10
// Configure serial port.
11
Serial.begin(115200);
12
delay(200);
13
}
14
15
void loop() {
16
// Read ambient light.
17
int resultA = als.readAmbientLight();
18
Serial.print("Ambient light: ");
19
Serial.println(resultA);
20
21
// Read ARGB light.
22
// A: Ambient, R: Red, G: Green, B: Blue light.
23
int a, r, g, b;
24
als.readARGBLight(a, r, g, b);
25
Serial.print("A: ");
26
Serial.print(a);
27
Serial.print(", R: ");
28
Serial.print(r);
29
Serial.print(", G: ");
30
Serial.print(g);
31
Serial.print(", B: ");
32
Serial.println(b);
33
34
// Print an empty line.
35
Serial.println("");
36
37
// Delay 1000ms = 1 seconds.
38
delay(1000);
39
}
Copied!

Result

After the application is uploaded to the device, it writes ambient light and RGB light values to the Serial Monitor. The example output should be like this:
1
Ambient light: 156
2
A: 156, R: 52, G: 57, B: 51
Copied!
The application runs forever until you clear it from memory.
Last modified 2yr ago
Copy link