-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrangeLED.ino
50 lines (39 loc) · 1.25 KB
/
OrangeLED.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* This example shows how to control the orange LED on the Nicla Sense Env board.
*
* Initial author: Sebastian Romero (s.romero@arduino.cc)
*/
#include "Arduino_NiclaSenseEnv.h"
void pulseLED(OrangeLED& led) {
// Fade in
for (uint8_t i = 0; i < 255; ++i) {
led.setBrightness(i);
delay(4);
}
// Fade out
for (int8_t i = 255; i >= 0; --i) {
led.setBrightness(i);
delay(4);
}
}
void setup() {
Serial.begin(115200);
// Wait for Serial to be ready with a timeout of 5 seconds
for(auto start = millis(); !Serial && millis() - start < 5000;);
NiclaSenseEnv device;
if (device.begin()) {
auto orangeLED = device.orangeLED();
Serial.print("🔢 Orange LED error status enabled: ");
Serial.println(orangeLED.errorStatusEnabled());
Serial.print("💡 Orange LED brightness: ");
Serial.println(orangeLED.brightness());
pulseLED(orangeLED);
// Enable sensor error indication on orange LED (LED should turn off if sensors are okay)
orangeLED.setErrorStatusEnabled(true);
} else {
Serial.println("🤷 Device could not be found. Please double-check the wiring.");
}
}
void loop() {
// Your main code here
}