#include #include #include int fd; char s[64]; int main() { int i; fd = open("/sys/class/gpio/export", O_WRONLY); if (fd < 0) { printf("GPIO export open error\n"); exit(1); } write(fd, 7, 2); close(fd); sprintf(s,"/sys/class/gpio/gpio%d/direction",7); fd = open(s, O_RDWR); if (fd < 0) { printf("GPIO %d direction open error\n",7); exit(1); } write(fd, "out", 2); close(fd); sprintf(s,"/sys/class/gpio/gpio%d/value",7); fd = open(s, O_RDWR); if (fd < 0) { printf("GPIO %d value open error\n",7); exit(1); } for (i=0; i<10; i++) { write(fd,"0",2); sleep(1); write(fd,"1",2); sleep(1); } close(fd); fd = open("/sys/class/gpio/unexport", O_WRONLY); if (fd < 0) { printf("GPIO unexport open error\n"); exit(1); } write(fd, 7, 2); close(fd); }