chiark / gitweb /
Minor updates to GPIO and README files
[wiringPi.git] / examples / test2.c
1
2 /*
3  * test2.c:
4  *      Simple test program to test the wiringPi functions
5  *      PWM test
6  */
7
8 #include <wiringPi.h>
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <stdint.h>
13
14 int main (void)
15 {
16   int bright ;
17
18   printf ("Raspberry Pi wiringPi PWM test program\n") ;
19
20   if (wiringPiSetup () == -1)
21     exit (1) ;
22
23   pinMode (1, PWM_OUTPUT) ;
24
25   for (;;)
26   {
27     for (bright = 0 ; bright < 1024 ; ++bright)
28     {
29       pwmWrite (1, bright) ;
30       delay (1) ;
31     }
32
33     for (bright = 1023 ; bright >= 0 ; --bright)
34     {
35       pwmWrite (1, bright) ;
36       delay (1) ;
37     }
38   }
39
40   return 0 ;
41 }