File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed
Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ Arduino LTR381RGB - Read All Sensors
3+
4+ This example reads the RGB, raw lux and lux values from the LTR381RGB
5+ sensor and continuously prints them to the Serial Monitor
6+ or Serial Plotter.
7+
8+ The circuit:
9+ - Arduino Uno WiFi R4
10+ - Modulino light sensor
11+
12+ This example code is in the public domain.
13+ */
14+
15+ #include " Arduino_LTR381RGB.h"
16+
17+ void setup () {
18+ Serial.begin (9600 );
19+ while (!Serial);
20+
21+ if (!RGB.begin ()) {
22+ Serial.println (" Failed to initialize rgb sensor!" );
23+ while (1 );
24+ }
25+ }
26+
27+ void loop () {
28+ int r, g, b, rawlux;
29+ int lux;
30+
31+ if (RGB.readAmbientLight (lux)) {
32+ Serial.print (" Raw Lux: " );
33+ Serial.print (rawlux);
34+ Serial.print (" \t " );
35+ }
36+
37+ if (RGB.readLux (lux)) {
38+ Serial.print (" Lumen: " );
39+ Serial.print (lux);
40+ Serial.print (" \t " );
41+ }
42+
43+ if (RGB.readColors (r, g, b)) {
44+ Serial.print (" Red: " );
45+ Serial.print (r);
46+ Serial.print (" \t Green: " );
47+ Serial.print (g);
48+ Serial.print (" \t Blue: " );
49+ Serial.println (b);
50+ }
51+ delay (1000 );
52+ }
You can’t perform that action at this time.
0 commit comments