Advertisement
silver2row

output.c

Mar 19th, 2022
1,704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include "sysfs-gpio.h"
  2. #include <stdio.h>
  3. // #include <unistd.h>
  4.  
  5. int main()
  6. {
  7.         struct Gpio gpio = GPIO_INITIALIZER;
  8.         gpio_open_output( &gpio, "/dev/gpio/relay-jp3", "low" );
  9.  
  10.         gpio_open( &gpio, "/dev/gpio/relay-jp3", "low" );
  11.         if( gpio_is_output( &gpio ) ) {
  12.                 gpio_write( &gpio, 0 );
  13.         } else {
  14.                 gpio_set_direction_output( &gpio, "high" );
  15.         }
  16.         gpio_set_direction_output(&gpio, "low");
  17.         int const timeout_ms = 3000;  // -1 = no timeout
  18.  
  19.         printf( "Print in %d milliseconds.\n ", timeout_ms );
  20.         gpio_close( &gpio );
  21.         return 0;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement