3 * Test of the software PWM driver. Needs 12 LEDs connected
6 * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
7 ***********************************************************************
8 * This file is part of wiringPi:
9 * https://projects.drogon.net/raspberry-pi/wiringpi/
11 * wiringPi is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * wiringPi is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************
36 int ledMap [NUM_LEDS] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13 } ;
38 int values [NUM_LEDS] = { 0, 17, 32, 50, 67, 85, 100, 85, 67, 50, 32, 17 } ;
45 if (wiringPiSetup () == -1)
47 fprintf (stdout, "oops: %s\n", strerror (errno)) ;
51 for (i = 0 ; i < NUM_LEDS ; ++i)
53 softPwmCreate (ledMap [i], 0, RANGE) ;
54 printf ("%3d, %3d, %3d\n", i, ledMap [i], values [i]) ;
57 fgets (buf, 80, stdin) ;
59 // Bring all up one by one:
61 for (i = 0 ; i < NUM_LEDS ; ++i)
62 for (j = 0 ; j <= 100 ; ++j)
64 softPwmWrite (ledMap [i], j) ;
68 fgets (buf, 80, stdin) ;
72 for (i = 100 ; i > 0 ; --i)
74 for (j = 0 ; j < NUM_LEDS ; ++j)
75 softPwmWrite (ledMap [j], i) ;
79 fgets (buf, 80, stdin) ;
83 for (i = 0 ; i < NUM_LEDS ; ++i)
84 softPwmWrite (ledMap [i], values [i]) ;
89 for (j = 0 ; j < NUM_LEDS - 1 ; ++j)
90 values [j] = values [j + 1] ;
91 values [NUM_LEDS - 1] = i ;