How it works...
This recipe defines a data structure called PINS, which will map each of the three buttons to their correct GPIO pin on the ESP8266. The get_buttons function creates Pin objects for each of these buttons with their correct PULL_UP settings. This get_buttons function is called in the main function and the returned dictionary is saved in the buttons variable.
The names variable is simply the sorted list of button names. It is created to ensure that the status update is always presented in alphabetical order. The get_status function loops through each button and calls the format function to generate the status line, which gets printed out each time the status is checked. The main loop enters into an infinite loop, printing the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access