Pico help config

Author Message


Joined: 05/10/2019
Location: United Kingdom
Posts: 1526
Posted: 08:24am 22 Oct 2021      

There are several ways. You have to make sure that the state doesn't keep changing while the button is pressed though. :)

One interesting way is to use the button to trigger an interrupt. The interrupt routine toggles a flag for use in your program then exits. This is nice because it can be triggered at any time, not just when the button is being scanned.

Another way (which can be combined) is to use the button to increment a counter. When it's zero the control flag is zero, when it's 1 the control flag is 1, when it's 2 it gets reset to zero.