3 * Test of the software PWM driver. Needs 8 LEDs connected
4 * to the Pi - e.g. Ladder board.
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 } ;
38 int values [NUM_LEDS] = { 0, 25, 50, 75, 100, 75, 50, 25 } ;
47 for (i = 0 ; i < NUM_LEDS ; ++i)
49 softPwmCreate (ledMap [i], 0, RANGE) ;
50 printf ("%3d, %3d, %3d\n", i, ledMap [i], values [i]) ;
53 fgets (buf, 80, stdin) ;
55 // Bring all up one by one:
57 for (i = 0 ; i < NUM_LEDS ; ++i)
58 for (j = 0 ; j <= 100 ; ++j)
60 softPwmWrite (ledMap [i], j) ;
64 fgets (buf, 80, stdin) ;
68 for (i = 100 ; i > 0 ; --i)
70 for (j = 0 ; j < NUM_LEDS ; ++j)
71 softPwmWrite (ledMap [j], i) ;
75 fgets (buf, 80, stdin) ;
79 for (i = 0 ; i < NUM_LEDS ; ++i)
80 softPwmWrite (ledMap [i], values [i]) ;
85 for (j = 0 ; j < NUM_LEDS - 1 ; ++j)
86 values [j] = values [j + 1] ;
87 values [NUM_LEDS - 1] = i ;