Hello,
I've been trying for the past couple of days to control the GPIO on my Pi 5 using C.
I managed to find a pdf named "GPIO Usage on Raspberry Pi Devices" that explain some of the libraries but most of them are for Python or deprecated. I tried to use "libgpiod" but I can't compile the program because of errors.
for reference I tried to run this code:and I get this error:
too few arguments to function gpiod_line_request_output
the version I use is:
pkg-config --modversion libgpiod outputs 1.6.63
gpiod: command not found (tried to install it and I get a message that it is already installed)
I would appreciate any good tutorial on how to start using the GPIO using C and more information about how to work with this library.
Thank you in advance![Smile :)]()
I've been trying for the past couple of days to control the GPIO on my Pi 5 using C.
I managed to find a pdf named "GPIO Usage on Raspberry Pi Devices" that explain some of the libraries but most of them are for Python or deprecated. I tried to use "libgpiod" but I can't compile the program because of errors.
for reference I tried to run this code:
Code:
#include <gpiod.h>#include <stdio.h>#include <unistd.h>#define CHIP "/dev/gpiochip0"#define LINE 17#define SLEEP_TIME 5000000int main() { struct gpiod_chip *chip; struct gpiod_line *line; int ret; chip = gpiod_chip_open(CHIP); if (!chip) { perror("Open chip failed"); return 1; } line = gpiod_chip_get_line(chip, LINE); if (!line) { perror("Get line failed"); gpiod_chip_close(chip); return 1; } ret = gpiod_line_request_output(line, "blink", 0); if (ret < 0) { perror("Request line as output failed"); gpiod_chip_close(chip); return 1; } while (1) { gpiod_line_set_value(line, 1); usleep(SLEEP_TIME); gpiod_line_set_value(line, 0); usleep(SLEEP_TIME); } gpiod_line_release(line); gpiod_chip_close(chip); return 0;}too few arguments to function gpiod_line_request_output
the version I use is:
pkg-config --modversion libgpiod outputs 1.6.63
gpiod: command not found (tried to install it and I get a message that it is already installed)
I would appreciate any good tutorial on how to start using the GPIO using C and more information about how to work with this library.
Thank you in advance
Statistics: Posted by ChenZal — Thu Nov 27, 2025 9:52 am