Skip to content

Instantly share code, notes, and snippets.

@microhobby
Last active January 30, 2020 05:39
Show Gist options
  • Save microhobby/a10a0052b8a2f0590f682335cb58f301 to your computer and use it in GitHub Desktop.
Save microhobby/a10a0052b8a2f0590f682335cb58f301 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <unistd.h>
#include <gpiod.h>
int main(int argc, char *argv[])
{
struct gpiod_chip *output_chip;
struct gpiod_line *output_line;
int line_value;
/* open /dev/gpiochip0 */
output_chip = gpiod_chip_open_by_number(0);
/* find BLUE_LED pin */
output_line = gpiod_chip_find_line(output_chip, "BLUE_LED");
/* config as output and set a description */
gpiod_line_request_output(output_line, "embarcadosDemo",
GPIOD_LINE_ACTIVE_STATE_HIGH);
while (1) {
line_value = !line_value;
gpiod_line_set_value(output_line, line_value);
sleep(1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment