Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
RGBLed Class Reference

A class to control a RGB LED. More...

#include <RGBLed.h>

Public Member Functions

void begin ()
 Initialize the RGB LED.
 RGBLed (uint8_t pinR, uint8_t pinG, uint8_t pinB)
 Construct a new RGBLed object.
void stop ()
 Stop the RGB LED.
void write (uint8_t r, uint8_t g, uint8_t b)
 
  • Writes PWM duty cycles to the RGB LED channels to produce the requested color. The LED is wired as common-anode, so inputs are inverted internally (0 = full on, 255 = off). A simple gamma correction is applied by squaring the 8-bit values.

Detailed Description

A class to control a RGB LED.

The JTKJ HAT includes a common-anode RGB LED driven by PWM on GPIO 18 (R), 19 (G), and 20 (B).

Colors are set with write using 8-bit channels (0 = full on, 255 = off). {@

Constructor & Destructor Documentation

◆ RGBLed()

RGBLed::RGBLed ( uint8_t pinR,
uint8_t pinG,
uint8_t pinB )

Construct a new RGBLed object.

Parameters
pinRGPIO pin connected to the red channel
pinGGPIO pin connected to the green channel
pinBGPIO pin connected to the blue channel

Member Function Documentation

◆ write()

void RGBLed::write ( uint8_t r,
uint8_t g,
uint8_t b )

  • Writes PWM duty cycles to the RGB LED channels to produce the requested color. The LED is wired as common-anode, so inputs are inverted internally (0 = full on, 255 = off). A simple gamma correction is applied by squaring the 8-bit values.

Parameters
rRed channel value (0 = full on, 255 = off)
gGreen channel value (0 = full on, 255 = off)
bBlue channel value (0 = full on, 255 = off)

The documentation for this class was generated from the following file: