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
63
●The above code will control all WS2812 lights to cycle through the three colors, press CTRL+C to exit
the program.
● If you want to control the color of a single lamp, you can use the following code, where i is the serial
number of the lamp, the serial number of the first lamp connected from the driver board is 0, and the second
lamp is 1. By analogy, R, G, B are the brightness of the corresponding three color channels:
LED.strip.setPixelColor(i, Color(R, G, B))
LED.strip.show()
●Instantiate the object and execute the method function. The function colorWipe () needs to pass in three
parameters, namely R, G, and B, which correspond to the brightness of the three primary colors of red, green,
and blue. The value range is 0- 255, the larger the value, the higher the brightness of the corresponding color
channel. If the values of the three color channels are the same, white light is emitted. Specific examples are as
follows:
if __name__ == '__main__':
LED = LED()
try:
while 1:
LED.colorWipe(255, 0, 0) # All the lights turn red
time.sleep(1)
LED.colorWipe(0, 255, 0) # All lights turn green
time.sleep(1)
LED.colorWipe(0, 0, 255) # All lights turn blue
time.sleep(1)
except:
LED.colorWipe(Color(0,0,0)) # Turn off all lights
●Note: You must use the Color () method to pack the RGB values and then pass them to setPixelColor ()