User Tools

Site Tools


using_a_breakout_button

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
using_a_breakout_button [2026/07/15 19:37] – [The Code] walkeradminusing_a_breakout_button [2026/07/15 20:02] (current) walkeradmin
Line 84: Line 84:
     if button.value() == 0:   # Button pressed (LOW)     if button.value() == 0:   # Button pressed (LOW)
         print("Button pressed — stopping program.")         print("Button pressed — stopping program.")
 +        all_off()
         break                 # Exit the loop and end main.py         break                 # Exit the loop and end main.py
 ####################### CHECK BREAKOUT BUTTON ########################## ####################### CHECK BREAKOUT BUTTON ##########################
Line 116: Line 117:
 \\  \\ 
 \\  \\ 
 +However, if you read the code, you can see the button value is read as the <color #ffc90e>Amber</color> LED is turned on after the <color #22b14c>Green</color> LED>. So it is quite easy to time right if you don't want to hold the button for 8 seconds.
 +\\ 
 +\\ 
 +=== Example ===
 +\\ 
 +<color #ed1c24>***Remember*** - We must save this code to our Raspberry Pi Pico as a file called main.py.</color>
 +\\ 
 +\\ 
 +This will enable to code to run on the Pico boot up.
 +\\ 
 +\\ 
 +Here is the button in action.
 +\\ 
 +\\ 
 +{{ :traffic-light-breakout-button-sim.mp4?900x634 |}}
 +\\ 
 +Using a button like this means you can never get you Pico stuck in a software loop with little to no way of recovery (without wiping it completely).
 +\\ 
 +\\ 
 +----
  
using_a_breakout_button.1784144268.txt.gz · Last modified: by walkeradmin