1
1
/*
2
2
This example code will walk you through how to set the interrupts on the
3
- SparkFun VEML6030 Ambient Light Sensor.
3
+ SparkFun VEML6030 Ambient Light Sensor. You can set both high and low
4
+ thresholds as well as how many values must be below or above the threshold
5
+ before an interrupt occurs. This example does require the interrupt pin on
6
+ the product to be connected a pin on your micro-controller.
4
7
5
- SparkFun Electronics
8
+ SparkFun Electronics
6
9
Author: Elias Santistevan
7
10
Date: July 2019
8
11
16
19
#include < Wire.h>
17
20
#include " SparkFun_VEML6030_Ambient_Light_Sensor.h"
18
21
22
+ // Close the address jumper on the product for addres 0x10.
19
23
#define AL_ADDR 0x48
20
24
21
25
SparkFun_Ambient_Light light (AL_ADDR);
@@ -46,9 +50,6 @@ void setup(){
46
50
Serial.begin (115200 );
47
51
pinMode (intPin, INPUT);
48
52
49
- Serial.println (float (time));
50
- Serial.println (time);
51
- Serial.println (float (" 1" ));
52
53
if (light.begin ())
53
54
Serial.println (" Ready to sense some light!" );
54
55
else
@@ -57,7 +58,7 @@ Serial.println(float("1"));
57
58
// Again the gain and integration times determine the resolution of the lux
58
59
// value, and give different ranges of possible light readings. Check out
59
60
// hoookup guide for more info. The gain/integration time also affects
60
- // interrupt threshold settings so ALWAYS set these first.
61
+ // interrupt threshold settings so ALWAYS set gain and time first.
61
62
light.setGain (gain);
62
63
light.setIntegTime (time);
63
64
@@ -73,7 +74,8 @@ Serial.println(float("1"));
73
74
light.setIntLowThresh (lowThresh);
74
75
light.setIntHighThresh (highThresh);
75
76
// Let's check that they were set correctly.
76
- // There are some rounding issues inherently.
77
+ // There are some rounding issues inherently in the IC's design so your lux
78
+ // may be one off.
77
79
Serial.print (" Low Threshold: " );
78
80
long lowVal = light.readLowThresh ();
79
81
Serial.print (lowVal);
0 commit comments