LED and Button¶
This section demonstrates LED basic functionalities and button support. A button event is captured and translated to 5 LED states: OFF, RED, BLUE, GREEN, WHITE.
// WS2813C
#include "ezWS2812gpio.h"
const pins_t myBoard = boardArduinoNanoMatter;
// WS2813
ezWS2812gpio myRGB(1, myBoard.ledData);
int inPin = 19; // pushbutton connected to digital pin 19
int val = 0; // variable to store the read value
int toggle = 0;
void setup()
{
pinMode(inPin, INPUT); // sets the digital pin 7 as input
myRGB.begin();
myRGB.set_pixel(0, 0, 0);
while(1)
{
val = digitalRead(inPin);
if (val)
{
toggle = (toggle + 1) % 4;
switch (toggle)
{
case 1:
delay(500);
myRGB.set_pixel(64, 0, 0);
case 2:
delay(500);
myRGB.set_pixel(0, 64, 0);
case 3:
delay(500);
myRGB.set_pixel(0, 0, 64);
break;
case 4:
delay(500);
myRGB.set_pixel(64, 64, 64);
break;
default:
delay(500);
myRGB.set_pixel(0, 0, 0);
break;
}
}
}
A more extensive LED demo can be found here: https://github.com/PervasiveDisplays/PDLS_EXT4_Basic_Matter/tree/main/examples/EXT4