Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <errno.h>
- void sysfs_write (const char *path, const char *value)
- {
- path=value;
- }
- int main(int argc, char** argv)
- {
- int toggle=1;
- int fd;
- //Write pin number to the export file
- sysfs_write( "/sys/class/gpio/export","183");
- //Set GPIO direction
- sysfs_write( "/sys/class/gpio/gpio183/direction","out");
- //Set Value
- sysfs_write( "/sys/class/gpio/gpio183/value","1");
- for(;;)
- {
- toggle = !toggle;
- if (toggle)
- {
- sysfs_write("/sys/class/gpio/gpio183/value","1");
- printf("Current value: 1 \n");
- }
- else
- {
- sysfs_write("/sys/class/gpio/gpio183/value","1");
- printf("Current value: 0 \n");
- }
- sleep(1);
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement