RUN PUSH BUTTON TO LED PROGRAM (push button goes to input16 and LED goes output25)
- Copy in16out25.cpp to your Desktop and then navigate there
install gpiod (copy 2 lines below to terminal)
-
sudo apt-get install libgpiod2 libgpiod-dev
-
sudo apt install gpiod
compile
- g++ in16out25.cpp -o in_out -lgpiod
run (CNTRL+C to exit)
- ./in_out
RUN SERIAL CHARACTER TRANSMIT PROGRAM. Use the TXD (Pi GPIO pin 14) and GND. These go to either a micro-controller RXD and GND (like Seeed Xiao) or a FTDI serial to USB cable (https://www.amazon.com/FTDI-TTL-232R/dp/B08PW7HHCD?th=1).
- Copy c_send.cpp to your Desktop and then navigate there
compile
- g++ c_send.cpp -o cs
run (CNTRL+X to exit)
- ./cs
Manually test with lines below. Copy and paste into terminal. check gpio line configuration (copy line below to terminal) gpioinfo
For Raspberry Pi 5 use gpiochip4 (For Raspberry Pi 4 use gpiochip0)
set output 25 high (copy line below to terminal)
gpioset gpiochip4 25=1
set output 25 low (copy line below to terminal)
gpioset gpiochip4 25=0
monitor input 16 state (copy line below to terminal)
gpioset gpiochip4 16
USEFUL LINKS:
Video of IO testing [PART 2 of 2]: https://youtu.be/koUr7oOyUXY Video, IO with GPIOD [PART 1 of 2]: https://youtu.be/cBXBhVYnU5Q
Access gpio with gpiod: https://www.ics.com/blog/gpio-programming-exploring-libgpiod-library
https://lloydrochester.com/post/hardware/libgpiod-blink-led-rpi/
old way sysfs, deprecated https://www.ics.com/blog/gpio-programming-using-sysfs-interface