SensorLib 0.5.1
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
aw9523_led.ino
Go to the documentation of this file.
1
7#include <IoExpanderDrv.hpp>
8
9#ifndef SENSOR_SDA
10#define SENSOR_SDA 17
11#endif
12
13#ifndef SENSOR_SCL
14#define SENSOR_SCL 18
15#endif
16
17// Pin 8 is P1_0, one of the six channels optimized for low dropout.
18// Connect the LED anode to its positive supply and cathode to P1_0.
19static constexpr uint8_t LED_PIN = 8;
20
22
23void setup()
24{
25 Serial.begin(115200);
26
27 if (!expander.begin(Wire, AW9523_DEFAULT_ADDRESS, SENSOR_SDA, SENSOR_SCL)) {
28 while (1) {
29 Serial.println("Failed to find AW9523 - check your wiring and address pins!");
30 delay(1000);
31 }
32 }
33
35 expander.analogWrite(LED_PIN, 0);
36 expander.setLedMode(LED_PIN);
37}
38
39void loop()
40{
41 for (int brightness = 0; brightness <= 255; ++brightness) {
42 expander.analogWrite(LED_PIN, brightness);
43 delay(5);
44 }
45 for (int brightness = 255; brightness >= 0; --brightness) {
46 expander.analogWrite(LED_PIN, brightness);
47 delay(5);
48 }
49}
@license MIT License
IoExpanderAW9523 expander
void setup()
#define SENSOR_SCL
#define SENSOR_SDA
void loop()
bool begin(SensorCommCustom::CustomCallback callback, uint8_t addr)
Initialize the sensor using custom callback interface.
Driver for the AW9523/AW9523B 16-channel GPIO and LED controller.
bool setLedCurrentRange(LedCurrentRange range)
Set the global maximum current range for all LED channels.
bool setLedMode(uint8_t pin, bool enable=true)
Enable or disable constant-current LED mode on one pin.
bool analogWrite(uint8_t pin, uint8_t value)
Set one constant-current LED channel's brightness.