Skip to content

Instantly share code, notes, and snippets.

@1nF0rmed
Created August 10, 2024 14:32
Show Gist options
  • Select an option

  • Save 1nF0rmed/90b8f2bb6728a413eeebbda59fd12527 to your computer and use it in GitHub Desktop.

Select an option

Save 1nF0rmed/90b8f2bb6728a413eeebbda59fd12527 to your computer and use it in GitHub Desktop.
Some lightsaber stuff
import time
import board
import random
import neopixel
import digitalio
from adafruit_debouncer import Button
pixel_pin = board.D1
num_pixels = 144
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, auto_write=False)
pixels.fill((0, 0, 255))
pixels.show()
pin = digitalio.DigitalInOut(board.D2)
pin.direction = digitalio.Direction.INPUT
pin.pull = digitalio.Pull.UP
switch = Button(pin, 1000, 3000, False)
while True:
switch.update()
if switch.pressed:
print("Pressed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment