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 4 Tutorial (#12)

4.3K views on YouTube

This video is becoming old, check out the new tutorial here: https://www.youtube.com/watch?v=dLjpDSY5lEQ

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

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

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

⏱️ Chapters
0:00 Your challenge
1:53 Code setup for all GPIOs we use
4:16 Detect when the button’s state goes from LOW to HIGH
9:27 Toggle between the 3 LEDs

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

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