ARGB Sample

This application demonstrates reading ambient light and RGB light values from the sensor.

To run the example:

  1. Open the IoT_Node_ALSGesture_ARGB sketch from the examples menu.

  2. Select Turta IoT Node from the Tools > Board menu.

  3. Select your device's COM port from Tools > Port menu.

  4. Open Serial Monitor from Tools > Serial Monitor.

  5. Select 115.200 baud from the Serial Monitor's status bar.

  6. Upload the code to your device.

Sample Code

#include <Turta_ALSGesture_Module.h>

// Create ALS Gesture Sensor instance.
Turta_ALSGesture_Module als;

void setup() {
  // Initialize ALS Gesture Sensor.
  als.begin();

  // Configure serial port.
  Serial.begin(115200);
  delay(200);
}

void loop() {
  // Read ambient light.
  int resultA = als.readAmbientLight();
  Serial.print("Ambient light: ");
  Serial.println(resultA);

  // Read ARGB light.
  // A: Ambient, R: Red, G: Green, B: Blue light.
  int a, r, g, b;
  als.readARGBLight(a, r, g, b);
  Serial.print("A: ");
  Serial.print(a);
  Serial.print(", R: ");
  Serial.print(r);
  Serial.print(", G: ");
  Serial.print(g);
  Serial.print(", B: ");
  Serial.println(b);
  
  // Print an empty line.
  Serial.println("");

  // Delay 1000ms = 1 seconds.
  delay(1000);
}

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:

Ambient light: 156
A: 156, R: 52, G: 57, B: 51

The application runs forever until you clear it from memory.

Last updated