File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
examples/ReadLightAndProximity/ReadLightAndProximity Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -15,25 +15,28 @@ LTR507 sensor;
15
15
16
16
void setup ()
17
17
{
18
- Serial.begin (115200 );
19
- sensor.init ();
18
+ Serial.begin (115200 ); // Start communication with PC via UART
19
+ sensor.init (); // Initialize sensor
20
20
}
21
21
22
22
void loop ()
23
23
{
24
- if (sensor.Available ()){
24
+ if (sensor.Available ()) // Check if sensor is available
25
+ {
25
26
uint16_t light;
26
27
light = sensor.getLightIntensity (); // get light intensity
27
28
if (light!=0 ){
28
29
Serial.print (" Light intensity: " );
29
- Serial.print (light);
30
+ Serial.print (light); // print light intensity
30
31
Serial.println (" lux." );
31
32
}
32
33
else {
33
- Serial.println (" Light intensity is not read or 0 lux." );
34
+ Serial.println (" Light intensity is not read or 0 lux." );// If there was some kind of error
35
+ // print message
34
36
}
35
37
}
36
- else Serial.println (" Communication error" );
38
+ else Serial.println (" Communication error" ); // If sensor is not available,
39
+ // there was communication error
37
40
Serial.println (" " );
38
41
delay (1000 );
39
42
}
You can’t perform that action at this time.
0 commit comments