*****************************************
Update, March 2024:
WiringPi has been updated to support the latest Raspberry Pi 4/5, but it is not included with default Raspberry Pi OS image. You can use the following commands in your Raspberry Pi Terminal to get WiringPi installed:
git clone https://github.com/mheidenreich/wirin...
cd wiringPiBasics
chmod u+x update_wiringpi.sh
sudo ./update_wiringpi.sh
The above will give you access to the 'gpio' command and you will be able to compile C programs that use wiringPi library, for example:
gcc -Wall blink.c -lwiringPi -o blink
*****************************************
This 2-part Raspberry Pi GPIO tutorial shows how to correctly use buttons with wiringPi (C Programming). While I use the buttons to control LEDs, you can use the same approach with any other electronic components (or code in a subroutine/function in general).
If you are using Raspberry Pi 4 you may receive an error when attempting to use the gpio command. Follow this guide to fix it:
http://wiringpi.com/wiringpi-updated-...
Part 1 video gives a general overview of wiringPi as of today, explains the concept of pull-up and pull-down resistors and demonstrates the circuit used in this tutorial.
Part 2 video covers the C coding part of this project, including:
GPIO port initialization and safe deactivation
Asynchronous button handlers using wiringPi interrupts
Button de-bouncing using time and sampling methods
Button callbacks using POSIX multi-threading
0:00 Intro
1:00 wiringPi Status
3:01 Pull-up and Pull-down Resistors
3:53 The Circuit
Full code: https://github.com/mheidenreich/butto...
(Note: code posted may contain small updates and/or bug fixes not shown in the video)
Disclaimer:
"Raspberry Pi" and the distinct logo are a trademark of the Raspberry Pi Foundation.
Music: Endless Motion By Bensound.com, https://www.bensound.com/