Proximity Sample
This application demonstrates reading proximity data from the sensor.
To run the example:
  1. 1.
    Open the IoT_Node_ALSGesture_Proximity 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_Proximity.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 proximity.
17
short resultP = als.readProximity();
18
Serial.print("Proximity: ");
19
Serial.println(resultP);
20
21
// Print an empty line.
22
Serial.println("");
23
24
// Delay 1000ms = 1 seconds.
25
delay(1000);
26
}
Copied!

Result

After the application is uploaded to the device, it writes proximity data to the Serial Monitor. The example output should be like this:
1
Proximity: 123
Copied!
The application runs forever until you clear it from memory.
Last modified 2yr ago
Copy link