Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

Toggle LEDs when Button is Pressed (Challenge 2) – Raspberry Pi 5 Tutorial (#12)

2.4K views on YouTube

In this Raspberry Pi tutorial you will combine 1 push button and 3 LEDs, to toggle between LEDs when you press the button.

🔥 Complete Raspberry Pi Course for Beginners 👉 https://rbcknd.com/raspberry-pi-for-beginners

👉 Raspberry Pi 5 Tutorial Playlist: https://www.youtube.com/playlist?list=PLLSegLrePWgIDKJTkdLyyQskh2HDdEL3y

⏱️ Chapters
(00:00) Your challenge
(01:13) A few tips to get started
(04:26) Setup all components + code structure
(07:43) Write the switch_led function
(13:52) Debounce the push button

👉 Get all my courses here 👉 https://rbcknd.com/all-courses

Twitter: https://twitter.com/RoboticsBackend
More Free Tutorials: https://roboticsbackend.com