"""
Digital Input Demo Code
Breadstick Innovations
April 22, 2024
https://learn.breadstick.ca/breadstick/breadsticks/raspberry-breadstick/code-examples/digital-input
"""
from board import *
from time import sleep
from digitalio import DigitalInOut, Direction, Pull
from adafruit_dotstar import DotStar
"""LED Setup"""
leds = DotStar(DOTSTAR_CLOCK, DOTSTAR_DATA, 24, brightness=0.02, auto_write=False)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
OFF = (0, 0, 0)
leds.fill(OFF)
leds.show()
"""Toggle Switch Setup"""
toggle_4 = DigitalInOut(D4)
toggle_4.switch_to_input()
"""Momentary Switch Setup"""
button_6 = DigitalInOut(D6)
button_6.switch_to_input(Pull.UP)
"""Loop"""
while True:
if toggle_4.value == True:
leds[0] = GREEN
else:
leds[0] = RED
if button_6.value == True:
leds[8] = GREEN
else:
leds[8] = RED
leds.show()
sleep(0.03)