MicroPython Cookbook
上QQ阅读APP看书,第一时间看更新

There's more...

In contrast to the first recipe in this chapter, there is no call to the sleep function to cause a delay between each loop. In this specific recipe, there is a reason why no delay is needed between each time the button state is polled. If one of the buttons is held down, then one of the lights will turn on and stay on without an issue.

In the case of the first recipe, a flood of print statements will occur while the button is being pressed. It is important to look at each scenario carefully to decide whether a delay is required between each poll.