/ NeoPixel_GoPro_Lens_Light / code.py
code.py
1 # SPDX-FileCopyrightText: 2018 Limor Fried for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 import time 6 7 import board 8 import neopixel 9 from analogio import AnalogIn 10 11 pot = AnalogIn(board.A1) # what pin the pot is on 12 pixpin = board.D0 # what pin the LEDs are on 13 numpix = 16 # number of LEDs in ring! 14 BPP = 4 # required for RGBW ring 15 16 ring = neopixel.NeoPixel(pixpin, numpix, bpp=BPP, brightness=0.9) 17 18 19 def val(pin): 20 # divides voltage (65535) to get a value between 0 and 255 21 return pin.value / 257 22 23 24 while True: 25 # Two lines for troubleshooting to see analog value in REPL 26 # print("A0: %f" % (pot.value / 65535 * 3.3)) 27 # time.sleep(1) 28 29 # change floating point value to an int 30 ring.fill((0, 0, 0, int(val(pot)))) 31 time.sleep(0.01)