课程: Raspberry Pi Weekly

免费学习该课程!

今天就开通帐号,24,600 门业界名师课程任您挑!

Input polling vs. interrupts

Input polling vs. interrupts

Hi. I'm Mark Niemann-Ross, and welcome to this week's edition of Raspberry Pi Weekly. Every week, we explore the Raspberry Pi and share useful tips. If you learned to program on a desktop or laptop computer, you may not be familiar with using interrupts, instead of polling. Desktop programming environments rarely support interrupts, but that's where the Raspberry Pi differs. With the Raspberry Pi GPIO, you can react to these interrupts in way you can't with other computers. Let's spend a bit of time exploring how to use interrupts with Python. If you're not clear on the difference between interrupts and polling, I highly recommend Barron Stone's chapter, titled Polling and Event-Driven Programming from his excellent Programming Foundations: Real-World Examples. For this discission, I've created a circuit with an HC-SR04, an LED, and a simple push-button. I've included a handout that describes how to build this…

内容