Instructions

Linker Kit Base Set Raspberry Pi
Veröffentlicht: 09.10.2018 Copyright by Maker Factory 8
3. DIE RGB-LED
Auf den folgenden 3 Seiten ist der Beispielcode noch einmal in Textform:
#!/usr/bin/env python3
# NeoPixel library strandtest example
# Author: Tony DiCola (tony@tonydicola.com)
#
# Direct port of the Arduino NeoPixel library strandtest example. Showcases
# various animaons on a strip of NeoPixels.
import me
from neopixel import *
import argparse
# LED strip conguraon:
LED_COUNT = 16 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN = 10 # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 10 # DMA channel to use for generang signal (try 10)
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shi)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
# Dene funcons which animate LEDs in various ways.
def colorWipe(strip, color, wait_ms=50):
"""Wipe color across display a pixel at a me."""
for i in range(strip.numPixels()):
strip.setPixelColor(i, color)
strip.show()
me.sleep(wait_ms/1000.0)
def theaterChase(strip, color, wait_ms=50, iteraons=10):
"""Movie theater light style chaser animaon."""
for j in range(iteraons):
for q in range(3):
for i in range(0, strip.numPixels(), 3):
strip.setPixelColor(i+q, color)
strip.show()
me.sleep(wait_ms/1000.0)
for i in range(0, strip.numPixels(), 3):
strip.setPixelColor(i+q, 0)