76
ls
4. Enter the command and press Enter to run the program:
sudo python3 LED.py
5. After running the program successfully, you will observe that the WS2812 light
turns red.
5.4.2 The main code program of this lesson
For the complete code, please refer to the file LED.py.
1.
import time
2.
from rpi_ws281x import *
The third-party library rpi_ws281x can be used to control the ws_2812 module
used on our products. The package name imported here is inconsistent with the
official routine, but this third-party library can be successfully used after testing and
using the import method here.
1.
class
LED:
2.
def
__init__(self):
3.
self.LED_COUNT
= 16
# 3. Set to the total number of LED lights on the robot product
4.
self.LED_PIN
= 12
# Set as the input pin number of the LED lamp group
5.
self.LED_FREQ_HZ = 800000
6.
self.LED_DMA
= 10
7.
self.LED_BRIGHTNESS = 255
8.
self.LED_INVERT = False
9.
self.LED_CHANNEL = 0
10.
# Use the above configuration items to create a strip
11.
self.strip = Adafruit_NeoPixel(
12.
self.LED_COUNT,
13.
self.LED_PIN,
14.
self.LED_FREQ_HZ,
15.
self.LED_DMA,
16.
self.LED_INVERT,
Summary of Contents for PiCar-Pro
Page 1: ......
Page 13: ...10 2 Introduction of GPIO pins 1 GPIO pin comparison table...
Page 16: ...13 Raspberry Pi through a computer or directly to control the Arduino...
Page 26: ...23 3 Then click Finish 4 The software interface after opening is as shown below...
Page 30: ...27 6 Click CHOOSE SD 7 Then select the SD card we need to burn...
Page 41: ...38 Click CONTINUE WITHOUT PERMISSION...
Page 62: ...59 Controlling the switches of Port1 Port2 Port3 on the development board...
Page 67: ...64...
Page 99: ...96 x1 x1 x1 x1 x1 A set of acrylic...
Page 108: ...105 Prepare the acrylic panel and acrylic gasket as shown in the picture above...
Page 112: ...109...
Page 114: ...111 Use M2 5 12 screws and M1 7 6 6 self tapping screws to fix...
Page 116: ...113...
Page 117: ...114...
Page 118: ...115...
Page 121: ...118...
Page 123: ...120...
Page 127: ...124 Use M3 4 screws to fix two L shaped aluminum alloys...
Page 128: ...125 Use M3 4 screws to pass through the aluminum alloy and L aluminum alloy to fix the servo...
Page 130: ...127...
Page 135: ...132 shown below Use M3 10 screws to fix aluminum alloy and aluminum alloy sheet...
Page 136: ...133 Install the tire and fix it with M4 locknut...
Page 137: ...134 Install small LED lights...
Page 139: ...136...
Page 141: ...138...
Page 142: ...139...
Page 145: ...142...
Page 147: ...144 Install the inner 4mm coupling and fix it with screws...
Page 153: ...150...
Page 154: ...151 The installation is complete 9 5 Circuit Wiring Diagram Robot HAT board interface diagram...
Page 168: ...165 Execution function 1 if __name__ __main__ 2 radar_scan 3 GPIO cleanup...
Page 177: ...174 Adeept is the name of the WIFI hotspot 12345678 is the password of the WIFI hotspot...
Page 178: ...175...