Advertisement
silver2row

Cape on my BBB in .c File Format

Apr 6th, 2020
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <fcntl.h>
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5.  
  6. int main()
  7. {
  8.   int fd = open( "/sys/class/gpio/gpio20/value", O_RDWR | O_CLOEXEC );
  9.   if( fd < 0 ) {
  10.     fprintf( stderr, "open: %m\n" );
  11.     exit(1);
  12.   }
  13.  
  14.   char c = '0';
  15.   write( fd, &c, 1 );
  16.   close( fd );
  17.  
  18.   return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement