Created
December 15, 2023 12:25
-
-
Save jenschr/dc00562bd362294e3faa5fc923077282 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************* | |
Minimal example for LTR329ALS sensor for LectureFeather | |
*********************************************************/ | |
#include "Adafruit_LTR329_LTR303.h" | |
#include <Adafruit_DotStar.h> | |
Adafruit_LTR329 ltr = Adafruit_LTR329(); | |
// There is only one pixel on the board | |
#define NUMPIXELS 1 | |
// Use these pin definitions for the LectureFeather ESP32-S3 | |
#define DATAPIN 33 | |
#define CLOCKPIN 21 | |
// This is the instance of the Dotstar class that is controlling the RGB LED | |
Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BGR); | |
void setup() { | |
Serial.begin(115200); | |
strip.begin(); // Initialize LED pins for output | |
strip.setBrightness(20); // Avoid blinding yourself | |
strip.setPixelColor(0, 10, 0, 0); // green only | |
strip.show(); // Turn all LEDs off ASAP | |
if ( ! ltr.begin() ) { | |
Serial.println("Couldn't find LTR sensor!"); | |
while (1) delay(10); | |
} | |
// Setup LTR sensor (see advanced demo in library for all options!) | |
Serial.println("Found LTR sensor!"); | |
ltr.setGain(LTR3XX_GAIN_4); | |
ltr.setIntegrationTime(LTR3XX_INTEGTIME_50); | |
ltr.setMeasurementRate(LTR3XX_MEASRATE_50); | |
} | |
void loop() { | |
uint16_t visible_plus_ir, infrared; | |
if (ltr.newDataAvailable()) { | |
bool valid = ltr.readBothChannels(visible_plus_ir, infrared); | |
if (valid) { | |
Serial.print("CH0 Visible + IR: "); | |
Serial.print(visible_plus_ir); | |
Serial.print("\tCH1 Infrared: "); | |
Serial.println(infrared); | |
} | |
} | |
// if you don't do much in a loop, always take a small break | |
delay(20); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment