Last active
July 12, 2023 07:49
-
-
Save Neradoc/8056725be1c209475fd09ffc37c9fad4 to your computer and use it in GitHub Desktop.
boot.py implementing waiting to start into safe mode on Raspberry pico
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import board | |
import time | |
from digitalio import DigitalInOut,Pull | |
led = DigitalInOut(board.LED) | |
led.switch_to_output() | |
safe = DigitalInOut(board.GP14) # <----- choose your pin with a button on it | |
safe.switch_to_input(Pull.UP) | |
def reset_on_pin(): | |
if safe.value is False: | |
import microcontroller | |
microcontroller.on_next_reset(microcontroller.RunMode.SAFE_MODE) | |
microcontroller.reset() | |
led.value = False | |
for x in range(16): | |
reset_on_pin() | |
led.value = not led.value | |
time.sleep(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment