Tutorial
Table Of Contents
- 1. Premise
- 2. Raspberry Pi System Installation and Developmen
- 3 Log In to The Raspberry Pi and Install The App
- 4 Assembly and Precautions
- 5 Controlling Robot via WEB App
- 6 Common Problems and Solutions(Q&A)
- 7 Set The Program to Start Automatically
- 8 Remote Operation of Raspberry Pi Via MobaXterm
- 9 How to Control WS2812 RGB LED
- 10 How to Control The Servo
- 11 How to Control DC Motor
- 12 Ultrasonic Module
- 13 Line Tracking
- 14 Make A Police Light or Breathing Light
- 15 Real-Time Video Transmission
- 16 Automatic Obstacle Avoidance
- 17 Why OpenCV Uses Multi-threading to Process Vide
- 18 OpenCV Learn to Use OpenCV
- 19 Using OpenCV to Realize Color Recognition and T
- 20 Machine Line Tracking Based on OpenCV
- 21 Create A WiFi Hotspot on The Raspberry Pi
- 22 Install GUI Dependent Item under Window
- 23 How to Use GUI
- 24 Control The WS2812 LED via GUI
- 25 Real-time Video Transmission Based on OpenCV
- 26 Use OpenCV to Process Video Frames on The PC
- 27 Enable UART
- 28 Control Your AWR with An Android Device
- Conclusion
61
9 How to Control WS2812 RGB LED
●WS2812 LED light is a commonly used module on our robot products. There are three WS2812 lights on
each module. Please pay attention when connecting. The signal line is different in direction, which needs to be
connected to WS2812 after being led out from the Raspberry Pi. The IN end of the LED lamp module, when the
next WS2812 LED module needs to be connected, the signal line is led out from the OUT end of the previous
WS2812 module and connected to the IN end of the next WS2812 LED.
●When using the Raspberry Pi with the driver board Motor HAT installed, the WS2812 LED module can
be connected to the WS2812 interface on the Motor HAT using a 3pin cable.
●We use a third-party library rpi_ws281x to control the WS2812 LED light, you can learn more about this
project on GitHub.
●If you connect the WS2812 LED module to Motor HAT's WS2812 interface, the signal line is equivalent
to the Raspberry Pi On GPIO 12, information about the pin number of the Raspberry Pi can refer to this official
document GPIO
●Use the following command to install rpi_ws281x for the Raspberry Pi. Since the Raspberry Pi has two
versions of Python built in, the Python3 code is used as an example, so pip3 is adopted to install the library.
pip3 install rpi-ws281x
● Next, we will explain the program. This program is written in the Raspberry Pi and executed in the
Raspberry Pi. For the specific method, you can refer to 8 Programming in the Raspberry Pi.
●Import dependencies
import time
from rpi_ws281x import *
●Construction of LED control class