KRITSADA

NeoPixel on esp8266 sample blink

May 28th, 2019
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from neopixel import NeoPixel
  2. from machine import Pin
  3. from time import sleep
  4. pin = Pin(10, Pin.OUT)   # set GPIO0 to output to drive NeoPixels
  5. np = NeoPixel(pin, 2)   # create NeoPixel driver on GPIO0 for 8 pixels
  6. while True :
  7.   np[0] = (0,0,20) # set the first pixel to white
  8.   np[1] = (0,20,0) # set the first pixel to white
  9.   np.write()              # write data to all pixels
  10.   sleep(0.4)
  11.   np[0] = (0,20,0) # set the first pixel to white
  12.   np[1] = (0,0,20) # set the first pixel to white
  13.   np.write()              # write data to all pixels
  14.   sleep(0.4)
  15.  
  16. #r, g, b = np[0]         # get first pixel colour
  17. #print (r,g,b)
Advertisement
Add Comment
Please, Sign In to add comment