Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. # NeoPixel library strandtest example
  2. # Author: Tony DiCola (tony@tonydicola.com)
  3. #
  4. # Direct port of the Arduino NeoPixel library strandtest example. Showcases
  5. # various animations on a strip of NeoPixels.
  6. import time
  7.  
  8. from rpi_ws281x import Adafruit_NeoPixel, Color
  9.  
  10. # LED strip configuration:
  11. LED_COUNT = 4 # Number of LED pixels.
  12. LED_PIN = 18 # GPIO pin connected to the pixels (must support PWM!).
  13. LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
  14. LED_DMA = 5 # DMA channel to use for generating signal (try 5)
  15. LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
  16. LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
  17. LED_CHANNEL = 0
  18. LED_STRIP = ws.WS2811_STRIP_GRB
  19.  
  20. # Create NeoPixel object with appropriate configuration.
  21. strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS,LED_CHANNEL,LED_STRIP)
  22. # Intialize the library (must be called once before other functions).
  23. strip.begin()
  24. strip.setPixelColor(0, Color(255, 0, 0)) #Red
  25. strip.setPixelColor(1, Color(0, 255, 0)) #Green
  26. strip.setPixelColor(2, Color(0, 0, 255)) #Blue
  27. strip.setPixelColor(3, Color(255, 255, 0)) #Yellow
  28. strip.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement