108
the standard program. If you are interested in this, you can try to expand more. We will offer the installation and
application methods of other functions in the follow-up tutorials. Please subscribe our Youtube channel for
more.
●Change LED Color:You can control the colors of the LEDs on the robot in real time by dragging these
three sliders. These three sliders correspond to the brightness of the three channels of RGB. In theory, you can
create 16,777,216 (256^ 3) kinds of colors through these three sliders.
24 Control The WS2812 LED via GUI
● You can use the program with a graphical interface written by yourself to communicate with the
Raspberry Pi on other devices to achieve the purpose of controlling the Raspberry Pi.
● The GUI programming method introduced in this chapter is completely done by Python language,
specifically, the Tkinter library is used.
·Tkinter is Python's standard GUI library. Python uses Tkinter to quickly create GUI applications. Because
Tkinter is built into the Python installation package, as long as Python is installed, you can import the Tkinter
library, and IDLE is also written in Tkinter. For simple graphical interface Tkinter can still cope with it.
●We use the Socket library to communicate between devices. Socket is also called "socket". Applications
usually send requests to the network or answer network requests through the "socket", so that the process
between the host or a computer can communicate.
●In this chapter, we take the remote control of the LED lights as an example, because almost all of our
robots are equipped with WS 2812 LED modules. This simpler example also helps novices to understand how
the desktop GUI program works communicate with the Raspberry Pi.
●Ready to burn the Raspbian Raspberry Pi, you can refer to the 9 module-WS2812 LED light for related
dependent libraries and connection methods. If you don't use Motor HAT, just connect the signal port (IN) of
WS2812 LED to GPIO12 (BCM 18) of Raspberry Pi.
●For the detailed definition of Raspberry Pi pins, you can see this link to
●Install the Python library used to control the WS2812 LED light. If it has not been installed or the robot
installation script has not been run, you can use the following command to install it in the Raspberry Pi console:
sudo pip3 install rpi_ws281x
●We will use the Raspberry Pi as the server and the PC as the client.
●The program of the server in the Raspberry Pi is as follows:
'''
These two libraries are used to control WS2812 LED lights
'''
from
rpi_ws281x
import
import
argparse
'''
Import socket library to be used for TCP communication
'''
*
understand:Raspberry Pi Pinout
Need help?
Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?