EasyManuals Logo

Freenove 4WD Smart Car Board for Raspberry Pi User Manual

Default Icon
132 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #78 background imageLoading...
Page #78 background image
Need support? support.freenove.com
74
Chapter 3 Module test (necessary)
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def rainbowCycle(self,strip, wait_ms=20, iterations=5):
"""Draw rainbow that uniformly distributes itself across all pixels."""
for j in range(256*iterations):
for i in range(self.strip.numPixels()):
self.strip.setPixelColor(i, self.wheel((int(i * 256 / self.strip.numPixels())
+ j) & 255))
self.strip.show()
time.sleep(wait_ms/1000.0)
def theaterChaseRainbow(self,strip, wait_ms=50):
"""Rainbow movie theater light style chaser animation."""
for j in range(256):
for q in range(3):
for i in range(0, self.strip.numPixels(), 3):
self.strip.setPixelColor(i+q, self.wheel((i+j) % 255))
self.strip.show()
time.sleep(wait_ms/1000.0)
for i in range(0, strip.numPixels(), 3):
strip.setPixelColor(i+q, 0)
led=Led()
# Main program logic follows:
if __name__ == '__main__':
print ('Program is starting ... ')
try:
while True:
print "Chaser animation"
led.colorWipe(led.strip, Color(255,0, 0)) # Red wipe
led.colorWipe(led.strip, Color(0, 255, 0)) # Green wipe
led.colorWipe(led.strip, Color(0, 0, 255)) # Blue wipe
led.theaterChaseRainbow(led.strip)
print "Rainbow animation"
led.rainbow(led.strip)
led.rainbowCycle(led.strip)
led.colorWipe(led.strip, Color(0,0,0),10)
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be
executed.
led.colorWipe(led.strip, Color(0,0,0),10)
Reference
strip.setPixelColor(Index,color(R,G,B))
This is a function of WS2812 library. It is the same as the previously customized ledIndex() function. It is
used to light up one LED and it has two input parameters. The first one is the LED number, the second
one is used to set the color of the LED. For example, strip.setPixelColor(1,Color(255, 0, 0)), and write
strip.show() in the next line, then LED1 will light red.

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove 4WD Smart Car Board for Raspberry Pi and is the answer not in the manual?

Freenove 4WD Smart Car Board for Raspberry Pi Specifications

General IconGeneral
BrandFreenove
Model4WD Smart Car Board for Raspberry Pi
CategoryMicrocontrollers
LanguageEnglish