diff --git a/main.c b/main.c index 6ab63e3..7da73fb 100644 --- a/main.c +++ b/main.c @@ -8,16 +8,16 @@ // prototype functions int gpio_export(const char *gpio); -int gpio_direction(int gpio, const char *direction); +int gpio_direction(int gpio, const char *direction); // this function int gpio_write(int gpio, int value); int main(int argc, char *argv[]){ int fd; - char pin[] = "17"; + char pin[] = "17"; // get gpio number from argument gpio_export(pin); - // pin direction + // pin direction - convert into functions fd = open("/sys/class/gpio/chip0/gpio17/direction", O_WRONLY); if(fd<0) { @@ -77,7 +77,7 @@ int gpio_export(const char *gpio){ perror("Error opening the GPIO path"); return -1; } - write(fd,"17",2); + write(fd,gpio,strlen(gpio)); close(fd); return 0; }