Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: vpenkoff on Sep 4th, 2012  |  syntax: C  |  size: 0.36 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2. #include <unistd.h>
  3.  
  4. int main(void) {
  5.         unsigned char byte, foo;
  6.         FILE *GPIOMOD;
  7.  
  8.         GPIOMOD=fopen("/dev/gpiomod", "w");
  9.         setvbuf(GPIOMOD, &foo, _IONBF, 1);
  10.         byte=1;
  11.         while (byte==64) {
  12.         printf("Byte value: %d\n", byte);
  13.         fwrite(&byte, 1, 1, GPIOMOD);
  14.        
  15.         byte <<=1;
  16.         if (byte == 0 ) byte = 1;
  17.         sleep(1);
  18.         }
  19.         fclose(GPIOMOD);
  20. }