Skip to content

Commit 2f11da2

Browse files
author
Main Push Robot
committed
Committing dev changes
1 parent 6f5b367 commit 2f11da2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

examples/ReadLightAndProximity/ReadLightAndProximity/ReadLightAndProximity.ino

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,28 @@ LTR507 sensor;
1515

1616
void setup()
1717
{
18-
Serial.begin(115200);
19-
sensor.init();
18+
Serial.begin(115200); //Start communication with PC via UART
19+
sensor.init(); //Initialize sensor
2020
}
2121

2222
void loop()
2323
{
24-
if(sensor.Available()){
24+
if(sensor.Available()) //Check if sensor is available
25+
{
2526
uint16_t light;
2627
light = sensor.getLightIntensity(); // get light intensity
2728
if(light!=0){
2829
Serial.print("Light intensity: ");
29-
Serial.print(light);
30+
Serial.print(light); // print light intensity
3031
Serial.println(" lux.");
3132
}
3233
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
3436
}
3537
}
36-
else Serial.println("Communication error");
38+
else Serial.println("Communication error"); // If sensor is not available,
39+
// there was communication error
3740
Serial.println("");
3841
delay(1000);
3942
}

0 commit comments

Comments
 (0)