-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathled_animation_resume_animation.py
40 lines (31 loc) · 1.21 KB
/
led_animation_resume_animation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# SPDX-FileCopyrightText: 2021 Alec Delaney
# SPDX-License-Identifier: MIT
"""
This example uses Pulse animation along with a connected push button to start
the animation when pressed
For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
a different form of NeoPixels.
"""
import board
import neopixel
from digitalio import DigitalInOut, Direction, Pull
from adafruit_led_animation.animation.pulse import Pulse
from adafruit_led_animation.color import RED
# Update to match the pin connected to your NeoPixels
pixel_pin = board.D6
# Update to match the number of NeoPixels you have connected
pixel_num = 32
# Update to matchpin connected to button that connect logic high when pushed
button_pin = board.D3
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)
button = DigitalInOut(button_pin)
button.direction = Direction.INPUT
button.pull = Pull.UP
# Create the animation and freeze it afterwards
pulse_animation = Pulse(pixels, speed=0.1, period=1, color=RED)
pulse_animation.freeze()
while True:
pulse_animation.animate()
# Pressing the button resumes (or in this case starts) the animation permanently
if not button.value:
pulse_animation.resume()