Deokgyu Yang | 2c7e86b | 2020-04-28 10:56:11 +0900 | [diff] [blame] | 1 | /* |
| 2 | * piglow.c: |
| 3 | * Very simple demonstration of the PiGlow board. |
| 4 | * This uses the SN3218 directly - soon there will be a new PiGlow |
| 5 | * devLib device which will handle the PiGlow board on a more easy |
| 6 | * to use manner... |
| 7 | * |
| 8 | * Copyright (c) 2013 Gordon Henderson. |
| 9 | *********************************************************************** |
| 10 | * This file is part of wiringPi: |
| 11 | * https://projects.drogon.net/raspberry-pi/wiringpi/ |
| 12 | * |
| 13 | * wiringPi is free software: you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU Lesser General Public License as published by |
| 15 | * the Free Software Foundation, either version 3 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * wiringPi is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU Lesser General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU Lesser General Public License |
| 24 | * along with wiringPi. If not, see <http://www.gnu.org/licenses/>. |
| 25 | *********************************************************************** |
| 26 | */ |
| 27 | |
| 28 | #include <wiringPi.h> |
| 29 | #include <sn3218.h> |
| 30 | |
| 31 | #define LED_BASE 533 |
| 32 | |
| 33 | int main (void) |
| 34 | { |
| 35 | int i, j ; |
| 36 | |
| 37 | wiringPiSetupSys () ; |
| 38 | |
| 39 | sn3218Setup (LED_BASE) ; |
| 40 | |
| 41 | for (;;) |
| 42 | { |
| 43 | for (i = 0 ; i < 256 ; ++i) |
| 44 | for (j = 0 ; j < 18 ; ++j) |
| 45 | analogWrite (LED_BASE + j, i) ; |
| 46 | |
| 47 | for (i = 255 ; i >= 0 ; --i) |
| 48 | for (j = 0 ; j < 18 ; ++j) |
| 49 | analogWrite (LED_BASE + j, i) ; |
| 50 | } |
| 51 | } |