3 * Simple sequence over the first 12 GPIO pins - LEDs
4 * Aimed at the Gertboard, but it's fairly generic.
5 * This version uses DRC totalk to the ATmega on the Gertboard
7 * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
8 ***********************************************************************
9 * This file is part of wiringPi:
10 * https://projects.drogon.net/raspberry-pi/wiringpi/
12 * wiringPi is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * wiringPi is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
24 ***********************************************************************
29 #include <drcSerial.h>
33 static int pinMap [] =
35 0, 1, 2, 3, // Pi Native
36 GERT_BASE + 2, GERT_BASE + 3, GERT_BASE + 4, GERT_BASE + 5,
37 GERT_BASE + 6, GERT_BASE + 7, GERT_BASE + 8, GERT_BASE + 9,
40 // Simple sequencer data
41 // Triplets of LED, On/Off and delay
61 0, 0, 1, // Extra delay
80 0, 0, 1, // Extra delay
82 0, 9, 0, // End marker
93 printf ("Raspberry Pi - 12-LED Sequence\n") ;
94 printf ("==============================\n") ;
96 printf ("Connect LEDs up to the first 4 Pi pins and 8 pins on the ATmega\n") ;
97 printf (" from PD2 through PB1 in that order,\n") ;
98 printf (" then sit back and watch the show!\n") ;
101 drcSetupSerial (GERT_BASE, 20, "/dev/ttyAMA0", 115200) ;
103 for (pin = 0 ; pin < 12 ; ++pin)
104 pinMode (pinMap [pin], OUTPUT) ;
110 l = data [dataPtr++] ; // LED
111 s = data [dataPtr++] ; // State
112 d = data [dataPtr++] ; // Duration (10ths)
114 if (s == 9) // 9 -> End Marker
120 digitalWrite (pinMap [l], s) ;
121 delay (d * analogRead (GERT_BASE) / 4) ;