yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
CUBE Pi Case📖
1. Assembly tutorial
  • 1. Installation video
  • 3. Hardware wiring instructions
2. CUBE Pi interface description and precautions
  • CUBE Pi interface description and precautions
3. Chassis driver tutorial
4. RGB light strip driver
  • RGB light strip driver
3. Fan drive
  • Fan drive
2. OLED display
  • OLED display
1. Install driver library
  • Install driver library
5. Set up auto-startup
  • Set up auto-startup
6. M.2 expansion board information (optional)
  • Installation steps
  • System Mount
Download
  • Code
  • System_Image_File
  • Communication Protocol
  • Instruction_Manual
Download ZIP

Welcome to CUBE Pi Case repository

当製品の日本語版マニュアル資料は、こちらからご取得ください。

RGB light strip driver

Driving the light bar

Driving the light bar1. Learning objectives2. Preparation before the experiment3. Use CubeRaspberry driver library to control RGB light strip1. Import CubeRaspberry driver library and create objects2. Set RGB light effects3. Set the speed of RGB light effects4. Set the color of RGB light effects5. Set the color of a single RGB light6. Code demonstration4. Use Jupyter lab to control the RGB light strip1. Import the CubeRaspberry driver library and create an object2. Set RGB light effects3. Set the speed of RGB light effects4. Set the color of RGB light effects5. Set the color of a single RGB light6. Delete the object7. Code demonstration8. Basic operation of Jupyter lab5. Experimental phenomenon

1. Learning objectives

  • Master the control of RGB light bar by Raspberry Pi series motherboard
  • Use CubeRaspberry driver library to control RGB light bar
  • Control RGB light bar through Jupyter lab

2. Preparation before the experiment

Install the Raspberry Pi chassis according to the assembly video tutorial. You can also refer to the "Raspberry Pi chassis_hardware wiring" tutorial document for installation. Here, the chassis expansion board and RGB light bar and fan hardware connection are shown.

1

Chassis expansion board3Pin interface2Pin interface
 RGB light stripFan

3. Use CubeRaspberry driver library to control RGB light strip

1. Import CubeRaspberry driver library and create objects

The name of the CubeRaspberry driver library is CubeRaspberryLib. Use CubeRaspberryLib to import the library in the program.

xxxxxxxxxx
from CubeRaspberryLib import CubeRaspberry

CubeRaspberryLib library functions needed to control RGB light strips:

xxxxxxxxxx
set_RGB_Effect(effect) #Set RGB light effects
set_RGB_Speed(speed) #Set RGB light effects speed
set_RGB_Color(color) #Set RGB light effects color
set_Single_Color(index, r, g, b) #Set single RGB light color

2. Set RGB light effects

| set_RGB_Effect(effect): Set RGB light effects | | :-------------------------------------------------: |

effect valueRGB light effects
0Turn off effects
1Monochrome breathing light
2Marquee
3Rainbow light
4Colorful light
5Flowing light
6Circular breathing light

3. Set the speed of RGB light effects

| set_RGB_Speed(speed): Set the speed of RGB light effects | | :-------------------------------------: |

speed valueRGB light effect speed
1Low speed
2Medium speed
3Fast

4. Set the color of RGB light effects

Note: This function can only be used to set the effect for single-color breathing lights and flowing lights.

| set_RGB_Color(color): Set the RGB light effect color | | :-------------------------------------: |

color valueRGB light effect color
0Red
1Green
2Blue
3Yellow
4Purple
5Cyan
6White

5. Set the color of a single RGB light

Note: All colors can be composed of different brightness levels of red, green and blue;

| set_Single_Color(index, r, g, b): Set the color of a single RGB light | | :-------------------------------------------------: |

ParametersSingle RGB light color
indexSerial number (0 - 13, 255)
rRed (0 - 255)
gGreen (0 - 255)
bBlue (0 - 255)

Index parameter: 0-13 corresponds to different lamp numbers; index = 255 means setting all RGB lamp colors.

r, g, b parameters: 0-255 represent different color brightness levels.

6. Code demonstration

  • Control RGB light bar effects and functions (python interactive interface: each statement needs to be run separately)

xxxxxxxxxx
from CubeRaspberryLib import CubeRaspberry
bot = CubeRaspberry(i2c_bus=1) bot.set_RGB_Effect(0) bot.set_RGB_Effect(1) bot.set_RGB_Effect(2) bot.set_RGB_Effect(3) bot.set_RGB_Effect(4) bot.set_RGB_Effect(6) bot.set_RGB_Speed ••(1) bot.set_RGB_Speed(2) bot.set_RGB_Speed(3) bot.set_RGB_Effect(1) bot.set_RGB_Color(0) bot.set_RGB_Color(1) bot.set_RGB_Color(2) bot.set_RGB_Color(3) bot.set_RGB_Color(4) bot.set_RGB_Color(6) bot.set_Single_Color(5,0,0, 255) bot.set_Single_Color(255,255,255,255) del bot

3584071b35fbb2cc965a64170bf63d2d

  • RGB light effect test (RGB_Test.py)

import time
from CubeRaspberryLib import CubeRaspberry
​
if __name__ ==  '__main__':
    bot = CubeRaspberry(i2c_bus=1)
    while True:
        bot.set_RGB_Effect(0) # 关闭特效5秒 Turn off the effect for 5 seconds
        time.sleep(5)
        bot.set_RGB_Effect(1) # 单色呼吸灯5秒 Monochromatic breathing lamp for 5 sec
        time.sleep(5)
        bot.set_RGB_Effect(2) # 跑马灯5秒 Marquee for 5 seconds
        time.sleep(5)
        bot.set_RGB_Effect(3) # 彩虹灯5秒 Rainbow lights for 5 seconds
        time.sleep(5)
        bot.set_RGB_Effect(4) # 炫彩灯5秒 Dazzle lights for 5 seconds
        time.sleep(5)
        bot.set_RGB_Effect(5) # 流水灯5秒 Running water lamp for 5 seconds
        time.sleep(5)
        bot.set_RGB_Effect(6) # 循环呼吸灯5秒 Circulate the lamp for 5 sec
        time.sleep(5)

image-20230717222959180

Note: Press Ctrl + C to terminate the run

4. Use Jupyter lab to control the RGB light strip

In Jupyter Create a new file in the lab interface and create the following code blocks, edit the following contents respectively (Fan_Test.ipynb):

1. Import the CubeRaspberry driver library and create an object

xxxxxxxxxx
# Import the CubeRaspberry driver library Import the CubeRaspberry driver library
from CubeRaspberryLib import CubeRaspberry
# Create an object Create an object
bot = CubeRaspberry(i2c_bus=1)

2. Set RGB light effects

xxxxxxxxxx
bot.set_RGB_Effect(0) # Turn off effects
xxxxxxxxxx
bot.set_RGB_Effect(1) # Monochrome breathing light
xxxxxxxxxx
bot.set_RGB_Effect(2) # Marquee
xxxxxxxxxx
bot.set_RGB_Effect(3) # Rainbow light lights
xxxxxxxxxx
bot.set_RGB_Effect(4) # Dazzling lights
xxxxxxxxxx
bot.set_RGB_Effect(5) # Running water lamps
xxxxxxxxxx
bot.set_RGB_Effect(6) # Circulation breathing lights

3. Set the speed of RGB light effects

xxxxxxxxxx
bot.set_RGB_Speed(1) # Low speed
xxxxxxxxxx
bot.set_RGB_Speed(2) # Medium speed
xxxxxxxxxx
bot.set_RGB_Speed(3) # High speed

4. Set the color of RGB light effects

xxxxxxxxxx
bot.set_RGB_Effect(1) # Monochrome breathing light
xxxxxxxxxx
bot.set_RGB_Color(0) # red red
xxxxxxxxxx
bot.set_RGB_Color(1) # green green
xxxxxxxxxx
bot.set_RGB_Color(2) # blue blue
xxxxxxxxxx
bot.set_RGB_Color(3) # yellow yellow
xxxxxxxxxx
bot.set_RGB_Color(4) # purple purple
xxxxxxxxxx
bot.set_RGB_Color(5) # cyan cyan
xxxxxxxxxx
bot.set_RGB_Color(6) # white white

5. Set the color of a single RGB light

xxxxxxxxxx
bot.set_Single_Color(5,255,0,0) # RGB lights Article 6 lamp beads are displayed in red
# RGB lights Article 6 lamp beads are displayed in red red
xxxxxxxxxx
bot.set_Single_Color(255,255,255,255) # All RGB beads are shown in white
# All RGB beads are shown in white

6. Delete the object

xxxxxxxxxx
# Delete the object Delete the object
del bot

7. Code demonstration

image-20230717224006162

image-20230717224114619

8. Basic operation of Jupyter lab

If you find that the code runs abnormally, it is recommended to follow the steps in the figure and then retest the code block.

image-20230717224225424

5. Experimental phenomenon

Calling the function in the CubeRaspberry driver library can achieve the corresponding phenomenon. Before setting the RGB light effect color and speed, you need to set the RGB light effect first.

For example: After executing the "Set Single RGB Light Color" function, directly using "Set RGB Light Effect Color" will not take effect. You need to first "Set RGB Light Effect 1 or 5" and then "Set RGB Light Effect Color".

CUBE Pi interface description and precautions
Fan drive

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/中文