Skip to content

Commit e751a9d

Browse files
Added example
1 parent fdb7230 commit e751a9d

File tree

2 files changed

+37
-76
lines changed

2 files changed

+37
-76
lines changed

examples/Example2_SensorSettings/Example2_SensorSettings.ino

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -18,90 +18,18 @@
1818
1919
You should have received a copy of the GNU General Public License
2020
along with this program. If not, see <http://www.gnu.org/licenses/>.
21-
22-
23-
---AVAILABLE FUNCTIONS---
24-
AS726X(TwoWire &wirePort = Wire, byte gain = 3, byte measurementMode = 3);
25-
void takeMeasurements();
26-
void takeMeasurementsWithBulb();
27-
void printMeasurements();
28-
void printUncalibratedMeasurements();
29-
byte getTemperature();
30-
float getTemperatureF();
31-
void setMeasurementMode(byte mode);
32-
boolean dataAvailable();
33-
void enableIndicator();
34-
void disableIndicator();
35-
void setIndicatorCurrent(byte current);
36-
void enableBulb();
37-
void disableBulb();
38-
void setBulbCurrent(byte current);
39-
void softReset();
40-
void setGain(byte gain);
41-
void setIntegrationTime(byte integrationValue);
42-
void enableInterrupt();
43-
void disableInterrupt();
44-
45-
46-
//Get the various color readings
47-
int getViolet();
48-
int getBlue();
49-
int getGreen();
50-
int getYellow();
51-
int getOrange();
52-
int getRed();
53-
54-
//Get the various NIR readings
55-
int getR();
56-
int getS();
57-
int getT();
58-
int getU();
59-
int getV();
60-
int getW();
61-
62-
//Returns the various calibration data
63-
float getCalibratedViolet();
64-
float getCalibratedBlue();
65-
float getCalibratedGreen();
66-
float getCalibratedYellow();
67-
float getCalibratedOrange();
68-
float getCalibratedRed();
69-
70-
float getCalibratedR();
71-
float getCalibratedS();
72-
float getCalibratedT();
73-
float getCalibratedU();
74-
float getCalibratedV();
75-
float getCalibratedW();
7621
*/
22+
7723
#include "AS726X.h"
78-
AS726X sensor;
24+
AS726X sensor;//Creates the sensor object
7925
byte GAIN = 0;
8026
byte MEASUREMENT_MODE = 0;
8127

8228
void setup() {
83-
sensor.begin(Wire, GAIN, MEASUREMENT_MODE);
84-
/*//You can also create an instance that runs on a different port (For instance, if you are using a teensy). The Gain and Measurement mode can also be changed.
85-
//Uncomment the below code and comment the above call of "sensor.begin()" to customize these settings.
86-
byte GAIN = 3;
87-
//Sets the gain
88-
//Sets the gain value
89-
//Gain 0: 1x (power-on default)
90-
//Gain 1: 3.7x
91-
//Gain 2: 16x
92-
//Gain 3: 64x
93-
byte MEASUREMENT_MODE = 3;
94-
//Sets the measurement mode
95-
//Mode 0: Continuous reading of VBGY (7262) / STUV (7263)
96-
//Mode 1: Continuous reading of GYOR (7262) / RTUX (7263)
97-
//Mode 2: Continuous reading of all channels (power-on default)
98-
//Mode 3: One-shot reading of all channels
99-
sensor.begin(Wire, GAIN, MEASUREMENT_MODE);
100-
//New declaration of sensor with different values
101-
*/
29+
sensor.begin(Wire, GAIN, MEASUREMENT_MODE);//Initializes the sensor with non default values
10230
}
10331

10432
void loop() {
10533
sensor.takeMeasurements();
106-
sensor.printMeasurements();//Prints out all measurements (calibrated)
34+
sensor.printMeasurements();
10735
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
This is a library written for the AS726X Spectral Sensor (Visible or IR) with I2C firmware
3+
specially loaded. SparkFun sells these at its website: www.sparkfun.com
4+
5+
Written by Nathan Seidle & Andrew England @ SparkFun Electronics, July 12th, 2017
6+
7+
https://github.com/sparkfun/Qwiic_Spectral_Sensor_AS726X
8+
9+
Do you like this library? Help support SparkFun. Buy a board!
10+
11+
Development environment specifics:
12+
Arduino IDE 1.8.1
13+
14+
This program is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU General Public License for more details.
18+
19+
You should have received a copy of the GNU General Public License
20+
along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*/
22+
23+
#include "AS726X.h"
24+
AS726X sensor;//Creates the sensor object
25+
26+
void setup() {
27+
sensor.begin(Wire, GAIN, MEASUREMENT_MODE);
28+
}
29+
30+
void loop() {
31+
sensor.takeMeasurementsWithBulb();
32+
sensor.printMeasurements();
33+
}

0 commit comments

Comments
 (0)