Linker Kit Base Set Raspberry Pi
Veröffentlicht: 09.10.2018 Copyright by Maker Factory 10
3. DIE RGB-LED
Beispielcode fortgeführt:
Führen Sie den Beispielcode mit folgenden Befehlen im Terminal aus:
# Main program logic follows:
if __name__ == '__main__':
# Process arguments
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--clear', acon='store_true', help='clear the display on exit')
args = parser.parse_args()
# Create NeoPixel object with appropriate conguraon.
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT,
LED_BRIGHTNESS, LED_CHANNEL)
# Inalize the library (must be called once before other funcons).
strip.begin()
print ('Press Ctrl-C to quit.')
if not args.clear:
print('Use "-c" argument to clear LEDs on exit')
try:
while True:
print ('Color wipe animaons.')
colorWipe(strip, Color(255, 0, 0)) # Red wipe
colorWipe(strip, Color(0, 255, 0)) # Blue wipe
colorWipe(strip, Color(0, 0, 255)) # Green wipe
print ('Theater chase animaons.')
theaterChase(strip, Color(127, 127, 127)) # White theater chase
theaterChase(strip, Color(127, 0, 0)) # Red theater chase
theaterChase(strip, Color( 0, 0, 127)) # Blue theater chase
print ('Rainbow animaons.')
rainbow(strip)
rainbowCycle(strip)
theaterChaseRainbow(strip)
except KeyboardInterrupt:
if args.clear:
colorWipe(strip, Color(0,0,0), 10)
cd /rpi_ws281x/python/examples
sudo python strandtest.py