Control onboard RGB LED of Waveshare ESP32-H2-Zero and ESP32-H2-DevKitM-1-N4, in Arduino framework.

Following code control the onboard RGB LED of Waveshare ESP32-H2-Zero and ESP32-H2-DevKitM-1-N4, in Arduino framework.

H2_BlinkRGB.ino
/*
  H2_BlinkRGB

*/

void setup() {
  // No need to initialize the RGB LED
}

// the loop function runs over and over again forever
void loop() {

  // * notice the color order
  rgbLedWrite(RGB_BUILTIN, RGB_BRIGHTNESS, 0, 0); // Red
  delay(1000);
  rgbLedWrite(RGB_BUILTIN, 0, RGB_BRIGHTNESS, 0); // Green
  delay(1000);
  rgbLedWrite(RGB_BUILTIN, 0, 0, RGB_BRIGHTNESS); // Blue
  delay(1000);
  rgbLedWrite(RGB_BUILTIN, 0, 0, 0); // Off / black
  delay(1000);

  int fade_speed = 10;
  for(int i=0; i<=255; i++){
    rgbLedWriteOrdered(RGB_BUILTIN, LED_COLOR_ORDER_RGB, i, 0, 0); // Red
    delay(fade_speed);
  }
  for(int i=255; i>=0; i--){
    rgbLedWriteOrdered(RGB_BUILTIN, LED_COLOR_ORDER_RGB, i, 0, 0); // Red
    delay(fade_speed);
  }
  for(int i=0; i<=255; i++){
    rgbLedWriteOrdered(RGB_BUILTIN, LED_COLOR_ORDER_RGB, 0, i, 0); // Green
    delay(fade_speed);
  }
  for(int i=255; i>=0; i--){
    rgbLedWriteOrdered(RGB_BUILTIN, LED_COLOR_ORDER_RGB, 0, i, 0); // Green
    delay(fade_speed);
  }
  for(int i=0; i<=255; i++){
    rgbLedWriteOrdered(RGB_BUILTIN, LED_COLOR_ORDER_RGB, 0, 0, i); // Blue
    delay(fade_speed);
  }
  for(int i=255; i>=0; i--){
    rgbLedWriteOrdered(RGB_BUILTIN, LED_COLOR_ORDER_RGB, 0, 0, i); // Blue
    delay(fade_speed);
  }

  delay(1000);

}


*Notice the R, G, B order.


Comments

Popular posts from this blog

Drive 320x240 ILI9341 SPI TFT using ESP32-S3 (NodeMCU ESP-S3-12K-Kit) using TFT_eSPI library, in Arduino Framework.

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library