Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Now output a value to it
- pFile = fopen("/sys/class/gpio/gpio30/value","w");
- if (pFile == NULL) {
- printf("Cannot open /sys/class/gpio/gpio30/value to write to the GPIO\n");
- exit(1);
- }
- int i;
- for (i=0; i < 10; i++) {
- fseek(pFile, 0, SEEK_SET);
- result = fprintf( pFile, "0" );
- if (result < 0) {
- printf("Cannot write to /sys/class/gpio/gpio30/value to set GPIO\n");
- fclose(pFile);
- exit(1);
- }
- usleep(500);
- fseek(pFile, 0, SEEK_SET);
- result = fprintf( pFile, "1" );
- if (result < 0) {
- printf("Cannot write to /sys/class/gpio/gpio30/value to set GPIO\n");
- fclose(pFile);
- exit(1);
- }
- usleep(500);
- // Adding this extra code screws up the high pulses
- // fseek(pFile, 0, SEEK_SET);
- // result = fprintf( pFile, "0" );
- // if (result < 0) {
- // printf("Cannot write to /sys/class/gpio/gpio30/value to set GPIO\n");
- // fclose(pFile);
- // exit(1);
- // }
- }
- fclose(pFile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement