def __init__(self, cursor, debounce_interval=0.01): CursorManager.__init__(self, cursor) self._pressed = 0 self._debouncer = Debouncer( lambda: bool(self._pressed & self._pad_btns["btn_a"]), interval=debounce_interval, )
def __init__(self, cursor: Cursor, debounce_interval: float = 0.01) -> None: CursorManager.__init__(self, cursor) self._debouncer = Debouncer( lambda: bool(self._pad_states & (1 << self._pad_btns["btn_a"])), interval=debounce_interval, )
def init_control(self): """Initialize the control here (i.e. set pin mode, get addresses, etc) Set the Pin for the button with the internal pull up resistor""" self.control_pin = self.gpio.DigitalInOut(self.pin_obj) self.control_pin.switch_to_input(pull=self.resistor) # If edge detection has been configured lets take advantage of that if self.edge_detection is not None: self.button = Debouncer(self.control_pin) if self.debounce is not None: self.button.interval = self.debounce
def __init__(self, dpad_l_pin=board.D3, dpad_r_pin=board.D4, dpad_u_pin=board.D1, dpad_d_pin=board.D0): # Setup DPAD # self.left_pin = DigitalInOut(dpad_l_pin) self.left_pin.direction = Direction.INPUT self.left_pin.pull = Pull.UP self.left = Debouncer(self.left_pin) self.right_pin = DigitalInOut(dpad_r_pin) self.right_pin.direction = Direction.INPUT self.right_pin.pull = Pull.UP self.right = Debouncer(self.right_pin) self.up_pin = DigitalInOut(dpad_u_pin) self.up_pin.direction = Direction.INPUT self.up_pin.pull = Pull.UP self.up = Debouncer(self.up_pin) self.down_pin = DigitalInOut(dpad_d_pin) self.down_pin.direction = Direction.INPUT self.down_pin.pull = Pull.UP self.down = Debouncer(self.down_pin)
def demoLoop(): led = digitalio.DigitalInOut(board.D13) led.direction = digitalio.Direction.OUTPUT touchA0 = touchio.TouchIn( board.A0 ) #built-in capacitive sensor. needs no external h/w except 1MOhm pulldown touchSwA0 = Debouncer(touchA0) testObservable = Observable('testObservable', lambda: random.randint(0,1000) < 1,\ 'something has happened', 'call me', 12345, event='random', reason='Dunno', led=led) #an observer with a random check testTimer = TimerObservable('testTimer', period=1000, led=led) #period is in ms testWentTrue = WentTrueObservable('testWentTrue', inp=touchSwA0, led=led) observer1 = Observer('observer1', testObservable) observer2 = Observer('observer2', testWentTrue) observer3 = Observer('observer3', testTimer) observerableList = [testObservable, testWentTrue, testTimer] #The forever loop. Causes observable to check their events and then notify their observers. while True: for obs in observerableList: res = obs.check( ) #ask this observable to check it event. This will cause a notify if it has happened if res and obs.name == 'testObservable': #did testObservable happen? if observer1 in testObservable._observers: #if so, remove observer1. He's finished now testObservable.deregister( observer1 ) #and here is how you can deregister. Would be useful to be able to reregister
class PiperJoystickZ: def __init__(self, joy_z_pin=board.D2): self.joy_z_pin = DigitalInOut(joy_z_pin) self.joy_z_pin.direction = Direction.INPUT self.joy_z_pin.pull = Pull.UP self.joy_z = Debouncer(self.joy_z_pin) def update(self): self.joy_z.update() def zPressed(self): return not self.joy_z.value def zPressedEvent(self): return self.joy_z.fell def zReleasedEvent(self): return self.joy_z.rose
class DebouncedCursorManager(CursorManager): """Simple interaction user interface interaction for Adafruit_CursorControl. This subclass provide a debounced version on the A button and provides queries for when the button is just pressed, and just released, as well it's current state. "Just" in this context means "since the previous call to update." :param adafruit_cursorcontrol cursor: The cursor object we are using. """ def __init__(self, cursor, debounce_interval=0.01): CursorManager.__init__(self, cursor) self._pressed = 0 self._debouncer = Debouncer( lambda: bool(self._pressed & self._pad_btns["btn_a"]), interval=debounce_interval, ) @property def is_clicked(self): """Returns True if the cursor button was pressed during previous call to update() """ return self._debouncer.rose pressed = is_clicked @property def released(self): """Returns True if the cursor button was released during previous call to update() """ return self._debouncer.fell @property def held(self): """Returns True if the cursor button is currently being held """ return self._debouncer.value def update(self): """Updates the cursor object.""" self._pressed = self._pad.get_pressed() self._check_cursor_movement(self._pressed) self._debouncer.update()
def init(self): """ Connect to the device """ self.pin_obj = getattr(board, self.pin) self.gpio = digitalio self._state = 0 # Used to track changes self.previous_state = self._state if re.match(r'D\d+$', self.pin): self.is_digital = True elif re.match(r'A\d+$', self.pin): self.is_digital = False else: self.is_digital = True if self.resistor is not None: if self.resistor == "up" or self.resistor == digitalio.Pull.UP: self._resistor = digitalio.Pull.UP elif self.resistor == "down" or self.resistor == digitalio.Pull.DOWN: self._resistor = digitalio.Pull.DOWN else: # Unknown resistor pull, defaulting to None self.config['resistor'] = self._resistor = None else: # Unknown resistor pull, defaulting to None self.config['resistor'] = self._resistor = None self._control_pin = self.gpio.DigitalInOut(self.pin_obj) self._control_pin.switch_to_input(pull=self._resistor) # Switches use debounce for better detection # TODO: get rid of this to allow long press, release, and press detection if self.type == 'switch': self.config['edge_detection'] = 'both' if self.edge_detection is not None: self._control = Debouncer(self._control_pin) if self.debounce is not None: self._control.interval = self.debounce self.reset_elapsed_time() return True
def __init__(self, cursor: Cursor, debounce_interval: float = 0.01) -> None: CursorManager.__init__(self, cursor) self._debouncers = {} for btn in self._pad_btns: self._debouncers[btn] = Debouncer( lambda btn=btn: bool( (self._pad_states & (1 << self._pad_btns[btn]))), interval=debounce_interval, )
def __init__(self, mc_top_pin=board.SCK, mc_middle_pin=board.MOSI, mc_bottom_pin=board.MISO): # Setup Minecraft Buttons # if mc_top_pin is not None: self.mc_top_pin = DigitalInOut(mc_top_pin) self.mc_top_pin.direction = Direction.INPUT self.mc_top_pin.pull = Pull.UP self.mc_top = Debouncer(self.mc_top_pin) else: self.mc_top = None if mc_middle_pin is not None: self.mc_middle_pin = DigitalInOut(mc_middle_pin) self.mc_middle_pin.direction = Direction.INPUT self.mc_middle_pin.pull = Pull.UP self.mc_middle = Debouncer(self.mc_middle_pin) else: self.mc_middle = None if mc_bottom_pin is not None: self.mc_bottom_pin = DigitalInOut(mc_bottom_pin) self.mc_bottom_pin.direction = Direction.INPUT self.mc_bottom_pin.pull = Pull.UP self.mc_bottom = Debouncer(self.mc_bottom_pin) else: self.mc_bottom = None
def demoLoop(): #indicators redLed = digitalio.DigitalInOut(board.D13) redLed.direction = digitalio.Direction.OUTPUT #objects that cause events touchA0 = touchio.TouchIn( board.A0 ) #built-in capacitive sensor. needs no external h/w except 1MOhm pulldown touchSwA0 = Debouncer(touchA0) #Events that determine if the objects they monitor hae done something interesting simpleEvent = SimpleEvent( obj=touchSwA0) #Watch the touch sw on A0 and report if it IS True timerEvent = TimerEvent( name='timerEvent', period=3000) #this one doesn't have an 'obj' as it monitors time wentTrueEvent = WentTrueEvent( obj=touchSwA0, name='wentTrueEvent' ) #Watch the touch sw on A0 and report if it GOES True #Observables that monitor events and notify registered observers testSimpleEventObservable = Observable(name='testSimpleEventObservable', event=simpleEvent) testTimerEventObservable = Observable(name='testTimerEventObservable', event=timerEvent) testWentTrueObservable = Observable(name='testWentTrueObservable', event=wentTrueEvent) #observers that get notifications from observables and do something about it simpleObserver = Observer( 'simpleObserver', testSimpleEventObservable, led=redLed) #who the observable should notify if event happens timerObserver = Observer('timerObserver', testTimerEventObservable, led=redLed) wentTrueObserver = Observer('wentTrueObserver', testWentTrueObservable, testWentTrueObservable, led=redLed) #list of observables to be checked in the 'forever' loop #observerableList = [testSimpleEventObservable, testTimerEventObservable, testWentTrueObservable] observerableList = [testWentTrueObservable] #The forever loop. Causes observable to check their events and then notify their observers. while True: for obs in observerableList: res = obs.check( ) #ask this observable to check it event. This will cause a notify if it has happened
def __init__(self, pin, name, type='Digital'): if type == 'Digital': self.pin = DigitalInOut(pin) self.debounced = Debouncer(self.pin) self.debounceRose = Debouncer(self.pin) self.debounceFell = Debouncer(self.pin) elif type == 'Analog': self.pin = AnalogIn(pin) self.name = name
def __init__(self, address, nums, interval=0.05): self.data = 0 self.address = address self.nums = nums self.signel = {} self.pressed = {} self.released = {} self.busMask = 0 self.bus = SMBus(1) self.isRunning = False for i in range(self.nums): self.signel[i] = Debouncer(self.readSignal(i), interval) self.busMask = self.busMask | (1 << i) thread = threading.Thread(target=self.run, args=()) thread.daemon = True thread.start()
def init_hw(): # Display i2c = busio.I2C(board.SCL, board.SDA) display = Sparkfun_SerLCD_I2C(i2c) display.clear() # Thermocouples spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) therm0 = MAX31855(spi, digitalio.DigitalInOut(pinsetup['therm0'])) therm1 = MAX31855(spi, digitalio.DigitalInOut(pinsetup['therm1'])) # Relays (high to enable because we go through the transistor switch) relay0 = digitalio.DigitalInOut(pinsetup['relay0']) relay0.direction = digitalio.Direction.OUTPUT relay0.value = False relay1 = digitalio.DigitalInOut(pinsetup['relay1']) relay1.direction = digitalio.Direction.OUTPUT relay1.value = False # Encoder setup enc = rotaryio.IncrementalEncoder(pinsetup['encoderA'], pinsetup['encoderB']) pb = digitalio.DigitalInOut(pinsetup['button']) pb.direction = digitalio.Direction.INPUT pb.pull = digitalio.Pull.DOWN switch = Debouncer(pb) # RGB on dial (low to enable) r = digitalio.DigitalInOut(pinsetup['r']) r.direction = digitalio.Direction.OUTPUT r.value = True g = digitalio.DigitalInOut(pinsetup['g']) g.direction = digitalio.Direction.OUTPUT g.value = True b = digitalio.DigitalInOut(pinsetup['b']) b.direction = digitalio.Direction.OUTPUT b.value = True return (display, therm0, therm1, relay0, relay1, enc, switch, (r, g, b))
IMAGE_FOLDER = ( "/bmps", "/bmps2", "/bmps3", ) # pylint: disable=invalid-name # --- Display setup --- matrix = Matrix(bit_depth=6) display = matrix.display ACCEL = adafruit_lis3dh.LIS3DH_I2C(busio.I2C(board.SCL, board.SDA), address=0x19) _ = ACCEL.acceleration # Dummy reading to blow out any startup residue pin_down = DigitalInOut(board.BUTTON_DOWN) pin_down.switch_to_input(pull=Pull.UP) button_down = Debouncer(pin_down) pin_up = DigitalInOut(board.BUTTON_UP) pin_up.switch_to_input(pull=Pull.UP) button_up = Debouncer(pin_up) ALIGN_RIGHT = True auto_advance = True i = 0 NUM_FOLDERS = 2 #first folder is numbered 0 slideshow = SlideShow( display, None, folder=IMAGE_FOLDER[i], order=0,
def make_crikit_signal_debouncer(pin): """Return a lambda to read the specified pin""" ss.pin_mode(pin, ss.INPUT_PULLUP) return Debouncer(lambda: ss.digital_read(pin))
def run(): display = Display() generator = Generator() button_a = Debouncer(make_debouncable(board.D9)) button_b = Debouncer(make_debouncable(board.D6)) button_c = Debouncer(make_debouncable(board.D5)) encoder_button = Debouncer(make_debouncable(board.D12)) encoder = rotaryio.IncrementalEncoder(board.D10, board.D11) current_position = None # current encoder position change = 0 # the change in encoder position delta = 0 # how much to change the frequency by shape = shapes.SINE # the active waveform frequency = 440 # the current frequency display.update_shape(shape) # initialize the display contents display.update_frequency(frequency) while True: encoder_button.update() button_a.update() button_b.update() button_c.update() current_position, change = get_encoder_change(encoder, current_position) if change != 0: if not button_a.value: delta = change * 1000 elif not button_b.value: delta = change * 100 elif not button_c.value: delta = change * 10 else: delta = change frequency = change_frequency(frequency, delta) if encoder_button.fell: shape = change_shape(shape) display.update_shape(shape) display.update_frequency(frequency) generator.update(shape, frequency)
# from adafruit_ble.uart_client import UARTClient # from adafruit_ble.scanner import Scanner # from adafruit_bluefruit_connect.packet import Packet from adafruit_bluefruit_connect.button_packet import ButtonPacket from adafruit_bluefruit_connect.color_packet import ColorPacket from neopixel import NeoPixel from board import NEOPIXEL, SWITCH from adafruit_debouncer import Debouncer from digitalio import DigitalInOut, Direction, Pull import adafruit_fancyled.adafruit_fancyled as fancy pin = DigitalInOut(SWITCH) # Set up built-in pushbutton switch pin.direction = Direction.INPUT pin.pull = Pull.UP switch = Debouncer(pin) pixels = NeoPixel(NEOPIXEL, 1) # Set up built-in NeoPixel AQUA = 0x00FFFF # (0, 255, 255) GREEN = 0x00FF00 # (0, 255, 0) ORANGE = 0xFF8000 # (255, 128, 0) RED = 0xFF0000 # (255, 0, 0) BLUE = 0x0000FF # (0, 0, 255) gradients = { 'Off': [(0.0, RED), (0.75, ORANGE)], 'On': [(0.0, GREEN), (1.0, AQUA)] } palette = fancy.expand_gradient(gradients['Off'], 30)
rainbow_chase, chase, rainbow_comet, auto_clear=True, auto_reset=True, ) def go_dark(): '''set all pixels to black''' pixels.fill(BLACK) pixels.show() # Debouncer ------------------------------------------------------ buttons = [Debouncer(mpr121[i]) for i in range(12)] # Audio Setup ------------------------------------------------------ spkr_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) spkr_enable.direction = digitalio.Direction.OUTPUT spkr_enable.value = True audio = AudioOut(board.SPEAKER) tracks = ( WaveFile(open("sounds/F2.wav", "rb")), # 0 WaveFile(open("sounds/G2.wav", "rb")), # 1 WaveFile(open("sounds/A2.wav", "rb")), # 2 WaveFile(open("sounds/Bb2.wav", "rb")), # 3
SPRITESHEET_FOLDER = "/bmps" DEFAULT_FRAME_DURATION = 0.1 # 100ms ANIMATION_DURATION = 5 AUTO_ADVANCE_LOOPS = 1 THRESHOLD = 20 # --- Display setup --- matrix = Matrix(bit_depth=4) sprite_group = displayio.Group(max_size=1) matrix.display.show(sprite_group) # --- Button setup --- pin_down = DigitalInOut(board.BUTTON_DOWN) pin_down.switch_to_input(pull=Pull.UP) button_down = Debouncer(pin_down) pin_up = DigitalInOut(board.BUTTON_UP) pin_up.switch_to_input(pull=Pull.UP) button_up = Debouncer(pin_up) AUTO_ADVANCE = True file_list = sorted( [ f for f in os.listdir(SPRITESHEET_FOLDER) if (f.endswith(".bmp") and not f.startswith(".")) ] ) if len(file_list) == 0:
class PiperMineCraftButtons: def __init__(self, mc_top_pin=board.SCK, mc_middle_pin=board.MOSI, mc_bottom_pin=board.MISO): # Setup Minecraft Buttons # if mc_top_pin is not None: self.mc_top_pin = DigitalInOut(mc_top_pin) self.mc_top_pin.direction = Direction.INPUT self.mc_top_pin.pull = Pull.UP self.mc_top = Debouncer(self.mc_top_pin) else: self.mc_top = None if mc_middle_pin is not None: self.mc_middle_pin = DigitalInOut(mc_middle_pin) self.mc_middle_pin.direction = Direction.INPUT self.mc_middle_pin.pull = Pull.UP self.mc_middle = Debouncer(self.mc_middle_pin) else: self.mc_middle = None if mc_bottom_pin is not None: self.mc_bottom_pin = DigitalInOut(mc_bottom_pin) self.mc_bottom_pin.direction = Direction.INPUT self.mc_bottom_pin.pull = Pull.UP self.mc_bottom = Debouncer(self.mc_bottom_pin) else: self.mc_bottom = None def update(self): if self.mc_top: self.mc_top.update() if self.mc_middle: self.mc_middle.update() if self.mc_bottom: self.mc_bottom.update() def topPressed(self): if self.mc_top: return not self.mc_top.value else: return False def topPressedEvent(self): if self.mc_top: return self.mc_top.fell else: return False def topReleasedEvent(self): if self.mc_top: return self.mc_top.rose else: return False def middlePressed(self): if self.mc_middle: return not self.mc_middle.value else: return False def middlePressedEvent(self): if self.mc_middle: return self.mc_middle.fell else: return False def middleReleasedEvent(self): if self.mc_middle: return self.mc_middle.rose else: return False def bottomPressed(self): if self.mc_bottom: return not self.mc_bottom.value else: return False def bottomPressedEvent(self): if self.mc_bottom: return self.mc_bottom.fell else: return False def bottomReleasedEvent(self): if self.mc_bottom: return self.mc_bottom.rose else: return False
class PiperDpad: def __init__(self, dpad_l_pin=board.D3, dpad_r_pin=board.D4, dpad_u_pin=board.D1, dpad_d_pin=board.D0): # Setup DPAD # self.left_pin = DigitalInOut(dpad_l_pin) self.left_pin.direction = Direction.INPUT self.left_pin.pull = Pull.UP self.left = Debouncer(self.left_pin) self.right_pin = DigitalInOut(dpad_r_pin) self.right_pin.direction = Direction.INPUT self.right_pin.pull = Pull.UP self.right = Debouncer(self.right_pin) self.up_pin = DigitalInOut(dpad_u_pin) self.up_pin.direction = Direction.INPUT self.up_pin.pull = Pull.UP self.up = Debouncer(self.up_pin) self.down_pin = DigitalInOut(dpad_d_pin) self.down_pin.direction = Direction.INPUT self.down_pin.pull = Pull.UP self.down = Debouncer(self.down_pin) def update(self): self.left.update() self.right.update() self.up.update() self.down.update() def leftPressed(self): return not self.left.value def leftPressedEvent(self): return self.left.fell def leftReleasedEvent(self): return self.left.rose def rightPressed(self): return not self.right.value def rightPressedEvent(self): return self.right.fell def rightReleasedEvent(self): return self.right.rose def upPressed(self): return not self.up.value def upPressedEvent(self): return self.up.fell def upReleasedEvent(self): return self.up.rose def downPressed(self): return not self.down.value def downPressedEvent(self): return self.down.fell def downReleasedEvent(self): return self.down.rose
def make_criket_signal_debouncer(pin): # create pin signal objects ss.pin_mode(pin, ss.INPUT_PULLUP) return Debouncer(lambda: ss.digital_read(pin))
# define and set up inputs to use the debouncer def make_criket_signal_debouncer(pin): # create pin signal objects ss.pin_mode(pin, ss.INPUT_PULLUP) return Debouncer(lambda: ss.digital_read(pin)) # The IR sensors on are pullups, connect to ground to activate clock_pin = make_criket_signal_debouncer(crickit.SIGNAL1) voice_1_pin = make_criket_signal_debouncer(crickit.SIGNAL2) voice_2_pin = make_criket_signal_debouncer(crickit.SIGNAL3) voice_3_pin = make_criket_signal_debouncer(crickit.SIGNAL4) voice_4_pin = make_criket_signal_debouncer(crickit.SIGNAL5) # Crickit capacitive touch pads touch_1_pad = Debouncer(lambda: crickit.touch_1.value) touch_4_pad = Debouncer(lambda: crickit.touch_4.value) touch_2_3_pad = Debouncer( lambda: crickit.touch_2.value and crickit.touch_3.value) crickit.continuous_servo_1.set_pulse_width_range(min_pulse=500, max_pulse=2500) speed = -0.04 #this is clockwise/forward at a moderate tempo def play_voice(vo): mixer.stop_voice(vo) mixer.play(samples[vo], voice=vo, loop=False) while True: clock_pin.update() #debouncer at work
# SPDX-FileCopyrightText: Copyright (c) 2021 John Park for Adafruit # # SPDX-License-Identifier: MIT # FunHouse Mail Slot Detector import board from adafruit_debouncer import Debouncer from digitalio import DigitalInOut, Pull from adafruit_funhouse import FunHouse beam_sense_pin = DigitalInOut(board.A0) # defaults to input beam_sense_pin.pull = Pull.UP # turn on internal pull-up resistor beam_sensor = Debouncer(beam_sense_pin) AMBER = 0xF0D000 BLUE = 0x00D0F0 RED = 0xFF0000 WHITE = 0xFFFFFF GRAY = 0x606060 funhouse = FunHouse(default_bg=None, scale=3) funhouse.peripherals.dotstars.brightness = 0.05 funhouse.peripherals.dotstars.fill(AMBER) # Create the labels funhouse.display.show(None) mail_label = funhouse.add_text(text="No Mail yet", text_position=(4, 14), text_color=AMBER) reset_label = funhouse.add_text(text="reset", text_position=(3, 70),
mode_initiated = False mode_duration_counter = 0 mode_phase = 0 HIGHEST_MODE = 10 icon_counter = 0 fastloop_counter = 0 # Built in red LED led = DigitalInOut(board.D13) led.direction = Direction.OUTPUT # Digital input with pullup on D7 button = DigitalInOut(board.D11) button.direction = Direction.INPUT button.pull = Pull.UP debounced_button = Debouncer(button) left_colors = [D_RED, D_RED, D_RED, D_RED, D_RED, D_RED, D_RED, D_RED] right_colors = [D_RED, D_RED, D_RED, D_RED, D_RED, D_RED, D_RED, D_RED] while True: # check_button() debounced_button.update() if debounced_button.fell: mode += 1 if mode > HIGHEST_MODE: mode = 0 mode_initiated = False mode_duration_counter = 0 mode_phase = 0
import board import digitalio import adafruit_rfm69 from adafruit_debouncer import Debouncer LED = digitalio.DigitalInOut(board.D13) LED.direction = digitalio.Direction.OUTPUT spi = board.SPI() ########################################## # buttons btn_red_pin = digitalio.DigitalInOut(board.A0) btn_red_pin.direction = digitalio.Direction.INPUT btn_red_pin.pull = digitalio.Pull.UP btn_red = Debouncer(btn_red_pin) ########################################## # RFM69 RADIO_FREQ_MHZ = 433.0 CS = digitalio.DigitalInOut(board.A4) RESET = digitalio.DigitalInOut(board.A5) rfm69 = adafruit_rfm69.RFM69(spi, CS, RESET, RADIO_FREQ_MHZ) rfm69.encryption_key = None rfm69.tx_power = 20 rfm69.bitrate = 250000 / 2 print("itsybitsy_rfm69_minimal.py") while True:
def __init__(self, joy_z_pin=board.D2): self.joy_z_pin = DigitalInOut(joy_z_pin) self.joy_z_pin.direction = Direction.INPUT self.joy_z_pin.pull = Pull.UP self.joy_z = Debouncer(self.joy_z_pin)
import time import board from digitalio import DigitalInOut, Direction, Pull from adafruit_debouncer import Debouncer button = DigitalInOut(board.D4) button.direction = Direction.INPUT button.pull = Pull.UP switch = Debouncer(button) while True: switch.update() if switch.fell: print('pressed') print('was released for ', switch.last_duration) elif switch.rose: print('released') print('was pressed for ', switch.last_duration) else: print('Stable for ', switch.current_duration) time.sleep(0.1)
i2c = busio.I2C(board.SCL, board.SDA) rtc = adafruit_ds3231.DS3231(i2c) audio = audioio.AudioOut(board.A0) strip = neopixel.NeoPixel(NEOPIXEL_PIN, NUM_PIXELS, brightness=1, auto_write=False) strip.fill(0) # NeoPixels off ASAP on startup strip.show() switch_io = DigitalInOut(SWITCH_PIN) switch_io.direction = Direction.INPUT switch_io.pull = Pull.UP switch = Debouncer(switch_io) # create a PWMOut object on Pin A2. pwm = pulseio.PWMOut(SERVO_PIN, duty_cycle=2**15, frequency=50) # Create a servo object, my_servo. servo = servo.ContinuousServo(pwm) servo.throttle = 0.0 # Set the time for testing # Once finished testing, the time can be set using the REPL using similar code if TESTING: # year, mon, date, hour, min, sec, wday, yday, isdst t = time.struct_time((2018, 12, 31, 23, 58, 55, 1, -1, -1)) # you must set year, mon, date, hour, min, sec and weekday # yearday is not supported, isdst can be set but we don't do anything with it at this time