#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
      int up;

     if(getuid()!=0)
      {
        printf("Error:wiringPi must be run as root.\n");
        return 1;
      }
     if(wiringPiSetup()==-1)
      {
        printf("Error:wiringPi setup failed.\n");
        return 1;
      }

      printf("PWM sur sortie GPIO18\n");
      pinMode(1,PWM_OUTPUT);
      pwmSetMode(PWM_MODE_MS);
      pwmWrite(1,0);      // Put PWM at 0%

	while(1)
      {
         for(up=0;up<=1024;up++)
			{
			pwmWrite(1,up);
			delay(2);
			}
         
         for(up=1024;up>=0;up--)
			{
			pwmWrite(1,up);
            delay(2);
            }
      }
  return 0;
}
