Skip to content

Commit b1dc4e2

Browse files
committed
update for v2.0 of library
1 parent b3146a5 commit b1dc4e2

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

examples/Example5_ProductionTest/Example5_ProductionTest.ino

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,71 +5,71 @@
55
* Paul Clark
66
* SparkFun Electronics
77
* December 7th 2021
8-
*
8+
*
99
* This is the code we use to test the SPX-18981 Ambient Light Sensor.
1010
* LED_BUILTIN will light up if the VEML7700 is detected correctly and the lux is within bounds.
11-
*
11+
*
1212
* Want to support open source hardware? Buy a board from SparkFun!
1313
* <br>SparkX Ambient Light Sensor - VEML7700 (SPX-18981): https://www.sparkfun.com/products/18981
14-
*
14+
*
1515
* Please see LICENSE.md for the license information
16-
*
16+
*
1717
*/
1818

1919
#include <SparkFun_VEML7700_Arduino_Library.h> // Click here to get the library: http://librarymanager/All#SparkFun_VEML7700
2020

21-
VEML7700 mySensor; // Create a VEML7700 object
21+
SparkFunVEML7700 mySensor; // Create a VEML7700 object
2222

2323
void setup()
2424
{
25-
Serial.begin(115200);
26-
Serial.println(F("VEML7700 Production Test"));
25+
Serial.begin(115200);
26+
Serial.println(F("VEML7700 Production Test"));
2727

28-
pinMode(LED_BUILTIN, OUTPUT);
29-
digitalWrite(LED_BUILTIN, LOW);
28+
pinMode(LED_BUILTIN, OUTPUT);
29+
digitalWrite(LED_BUILTIN, LOW);
3030
}
3131

3232
void loop()
3333
{
34-
delay(250); // Try every 0.25 seconds
34+
delay(250); // Try every 0.25 seconds
3535

36-
Wire.begin();
36+
Wire.begin();
3737

38-
Wire.beginTransmission(0x10); // Detect VEML7700 on address 0x10
39-
if (Wire.endTransmission() != 0)
40-
{
41-
digitalWrite(LED_BUILTIN, LOW);
42-
Wire.end();
43-
Serial.println(F("Error: nothing detected on address 0x10"));
44-
return;
45-
}
46-
47-
//Initialize sensor
48-
if (mySensor.begin() == false)
49-
{
50-
digitalWrite(LED_BUILTIN, LOW);
51-
Wire.end();
52-
Serial.println(F("Error: .begin failed"));
53-
return;
54-
}
38+
Wire.beginTransmission(0x10); // Detect VEML7700 on address 0x10
39+
if (Wire.endTransmission() != 0)
40+
{
41+
digitalWrite(LED_BUILTIN, LOW);
42+
Wire.end();
43+
Serial.println(F("Error: nothing detected on address 0x10"));
44+
return;
45+
}
5546

56-
delay(250); // Default integration time is 100ms
47+
// Initialize sensor
48+
if (mySensor.begin() == false)
49+
{
50+
digitalWrite(LED_BUILTIN, LOW);
51+
Wire.end();
52+
Serial.println(F("Error: .begin failed"));
53+
return;
54+
}
5755

58-
// Now we read the lux from the sensor
59-
float lux = mySensor.getLux(); // Read the lux
56+
delay(250); // Default integration time is 100ms
6057

61-
// Check the lux is within bounds
62-
if ((lux < 20.0) || (lux > 100000.0))
63-
{
64-
digitalWrite(LED_BUILTIN, LOW);
65-
Wire.end();
66-
Serial.print(F("Error: invalid lux reading: "));
67-
Serial.println(lux, 4);
68-
return;
69-
}
58+
// Now we read the lux from the sensor
59+
float lux = mySensor.getLux(); // Read the lux
60+
61+
// Check the lux is within bounds
62+
if ((lux < 20.0) || (lux > 100000.0))
63+
{
64+
digitalWrite(LED_BUILTIN, LOW);
65+
Wire.end();
66+
Serial.print(F("Error: invalid lux reading: "));
67+
Serial.println(lux, 4);
68+
return;
69+
}
7070

71-
// All good!
72-
Serial.println(F("Test passed!"));
73-
digitalWrite(LED_BUILTIN, HIGH);
74-
Wire.end();
71+
// All good!
72+
Serial.println(F("Test passed!"));
73+
digitalWrite(LED_BUILTIN, HIGH);
74+
Wire.end();
7575
}

0 commit comments

Comments
 (0)