#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int main ()
{
	int exportfd;
	
	exportfd = open( "/sys/class/gpio/export" , O_WRONLY );
	if( exportfd < 0)
	{
		printf( "Cannot open GPIO to export it \n");
		exit (1);
	}
	write( exportfd ,"913",4);
	close( exportfd );
	printf(" GPIO exported successfully \n " ); 

	int directionfd = open("/sys/class/gpio/gpio913/direction", O_RDWR);
	if( directionfd < 0){
		printf("cannot open the file");
		exit(1);	
	}
	write( directionfd , "out" , 4);
	close (directionfd);
	
	/* Get the GPIO value ready to be toggled */
	int valuefd = open( "/sys/class/gpio/gpio913/value" , O_RDWR );

	if ( valuefd < 0){
		printf(" Cannot open GPIO value \n " );
		exit (1);
	}
	printf(" GPIO value opened , now toggling ...\n " );
	/* toggle the GPIO forever , press control + c to stop it */
	while (1)
	{
		int i ;
		for(i=0;i<0xFF;i++){}
			printf(" GPI0  -off\n");
			write( valuefd , "1" , 2);			
			usleep(500000);

			printf(" GPI0  -on\n");
			write( valuefd , "0" , 2);
			usleep(500000);
	}
printf("blink program finished");
}