Proximity Sample

This application demonstrates reading proximity data from the sensor.

To run the example:

  1. Open the IoT_Node_ALSGesture_Proximity 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

IoT_Node_ALSGesture_Proximity.ino
IoT_Node_ALSGesture_Proximity.ino
#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 proximity.
short resultP = als.readProximity();
Serial.print("Proximity: ");
Serial.println(resultP);
// Print an empty line.
Serial.println("");
// Delay 1000ms = 1 seconds.
delay(1000);
}

Result

After the application is uploaded to the device, it writes proximity data to the Serial Monitor. The example output should be like this:

Proximity: 123

The application runs forever until you clear it from memory.