yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Roboduino V2📖
0.Instruction manual
  • Instruction manual
1.Get started quickly
  • 01.Assembly of the Car
  • 02.Remote Control Car
  • 03.Common Problem Analysis
  • 04. Lithium Battery Pack and Charger Usage Guidelines
  • 05. Important Notes (Read Before Starting)
2.Environment Construction
  • 01.Serial port driver installation
  • 02.Arduino IDE Installation
  • 03.Arduino IDE usage
  • 04.Using third-party libraries
  • 05.Program compilation and upload
3.Basic car course
  • 01.RGB Control
  • 02.Serial Print
  • 03.KEY Read
  • 04.Buzzer control
  • 05.Logo Breath
  • 06.Servos Control
  • 07.Motor Control
  • 08.Ultrasonic Ranging
  • 09.Track Print
  • 10.Infrared Remote Print
  • 11.WIFI Camera
4.Advanced car course
  • 01.RGB Breath
  • 02.Play Music
  • 03.KEY Control RGB
  • 04.KEY Control Buzzer
  • 05.Serial Parse Data
  • 06.Parse Data Control Motor
  • 07.Parse Data Control RGB
  • 08.Parse Data Control Buzzer
  • 09.Parse Data Control Servo
5.Car motion control
  • 00.Mecanum wheel motion principle
  • 01.Car Vertical Movement
  • 02.Car Diagonal Movement
  • 03.Car Sideways Movement
  • 04.Car Rotational Movement
  • 05.Car Patrol
6.Comprehensive gameplay of car
  • 01.Car tracking
  • 02.Car Obstacle Avoid
  • 03.Car Follow Hand
  • 04.Car tracking Avoid
  • 05.Car Infrared Remote
  • 06.WiFi Control Car
  • 07.IR WiFi Control Car
7.AI vision course
  • 1. Cat(dog) detection
  • 2. Color recognition
  • 3. QR code instructions
  • 4. Person Recognition
  • 5. Face Detection
  • 6. Color Follows
  • 7. Face following
8.Expand peripherals
  • 01.Digital Tube Display
  • 02.Color Recognition
Download
  • Code
  • Library
  • Hardware manual
  • Software
  • 3D Model
  • Instruction Manual
Download ZIP

Welcome to Roboduino V2 repository

01.RGB Breath

RGB Breath

RGB BreathDevice connectionHardware connectionSoftware connectionRGB breathing effectControl principleControl pinsCode analysisExperimental results

Control the RGB light on the Robduino expansion board to display the breathing effect of 7 common colors.

Device connection

Hardware connection

Use Type-B data cable to connect Arduino Uno and computer.

Software connection

Open the "Arduino IDE" software and select the model and serial port number corresponding to the development board.

RGB breathing effect

Control principle

RGB lights are composed of red, green and blue LED lights:

Through the combination and brightness control of different color LEDs, the effect of RGB lights displaying various colors can be achieved;

On this basis, we control the brightness of different color LEDs to achieve the effect of breathing lights.

Control pins

Peripheral moduleArduino Uno
RGB6

Code analysis

Here is only a brief introduction to the code content. For detailed code, it is recommended to refer to the corresponding code file, which is provided in the download area!

  • Include Adafruit NeoPixel library

x
#include <Adafruit_NeoPixel.h>  // 包含Adafruit NeoPixel库 Include Adafruit NeoPixel library
  • Define RGB control pins and quantity

x
// 定义RGB控制引脚和数量 Define RGB control pins and quantity
#define RGB_PIN 6
#define RGB_NUM 1
  • Enumerate common colors

x
// 枚举常见颜色 Enumerate common colors
enum ColorType {
  BLACK,
  RED,
  GREEN,
  BLUE,
  YELLOW,
  MAGENTA,
  CYAN,
  WHITE,
};
  • Create an instance of the Adafruit_NeoPixel class

x
// 创建Adafruit_NeoPixel类的实例 Create an instance of the Adafruit_NeoPixel class
Adafruit_NeoPixel RGB = Adafruit_NeoPixel(RGB_NUM, RGB_PIN, NEO_GRB + NEO_KHZ800);
  • Set RGB display color

x
/**
 * @brief 设置RGB显示的颜色 Set RGB display color
 * @param color: 显示的颜色 Set the color
 * @retval 无 None
 */
void setRGBColor(ColorType color) {
  switch (color) {
    case RED:
      RGB.setPixelColor(0, RGB.Color(255, 0, 0));
      RGB.show();
      break;
    case GREEN:
      RGB.setPixelColor(0, RGB.Color(0, 255, 0));
      RGB.show();
      break;
    case BLUE:
      RGB.setPixelColor(0, RGB.Color(0, 0, 255));
      RGB.show();
      break;
    case YELLOW:
      RGB.setPixelColor(0, RGB.Color(255, 255, 0));
      RGB.show();
      break;
    case MAGENTA:
      RGB.setPixelColor(0, RGB.Color(255, 0, 255));
      RGB.show();
      break;
    case CYAN:
      RGB.setPixelColor(0, RGB.Color(0, 255, 255));
      RGB.show();
      break;
    case WHITE:
      RGB.setPixelColor(0, RGB.Color(255, 255, 255));
      RGB.show();
      break;
    default:
      RGB.setPixelColor(0, RGB.Color(0, 0, 0));
      RGB.show();
      break;
  }
}
  • Set the RGB breath effect

x
/**
 * @brief 设置RGB灯呼吸效果 Set the RGB breath effect
 * @param red: 红色亮度 Red brightness
 * @param green: 绿色亮度 Green brightness
 * @param blue: 蓝色亮度 Blue brightness
 * @retval 无 None
 */
void setColorBreathShow(uint8_t red, uint8_t green, uint8_t blue) {
  for (int i = 0; i < 256; i++) {
    RGB.setPixelColor(0, RGB.Color((red * i) / 255, (green * i) / 255, (blue * i) / 255));
    RGB.show();
    delay(10);
  }

  for (int i = 255; i >= 0; i--) {
    RGB.setPixelColor(0, RGB.Color((red * i) / 255, (green * i) / 255, (blue * i) / 255));
    RGB.show();
    delay(10);
  }
}
  • Initialization Code

xxxxxxxxxx
void setup() {
  RGB.begin();  // 初始化RGB Initialize RGB
  RGB.show();   // 刷新RGB显示 Refresh RGB display
}
  • Looping code

xxxxxxxxxx
void loop() {
  setColorBreathShow(0, 0, 0);        // 黑色 BLACK
  setColorBreathShow(255, 0, 0);      // 红色 RED
  setColorBreathShow(0, 255, 0);      // 绿色 GREEN
  setColorBreathShow(0, 0, 255);      // 蓝色 BLUE
  setColorBreathShow(255, 255, 0);    // 黄色 YELLOW
  setColorBreathShow(255, 0, 255);    // 品红色 MAGENTA
  setColorBreathShow(0, 255, 255);    // 青色 CYAN
  setColorBreathShow(255, 255, 255);  // 白色 WHITE
}

Experimental results

After compiling the program successfully, upload the code to the Arduino Uno development board.

After the program is started, the RGB light will display 7 common colors of breathing effects in turn!

xxxxxxxxxx
The burning program cannot use other programs to occupy the serial port or external serial communication module (for example: WiFi camera module), otherwise the program cannot be burned or an error message will be prompted!
WIFI Camera
Play Music

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文