3 * Simple sequence over 6 pins on a remote DRC board.
4 * Aimed at the Gertduino, but it's fairly generic.
5 * This version uses DRC to talk to the ATmega on the Gertduino
7 * Copyright (c) 2012-2014 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 GERT_BASE + 6, GERT_BASE + 5, GERT_BASE + 3, GERT_BASE + 10, GERT_BASE + 9, GERT_BASE + 13,
38 // Simple sequencer data
39 // Triplets of LED, On/Off and delay
53 0, 0, 1, // Extra delay
66 0, 0, 1, // Extra delay
68 0, 9, 0, // End marker
79 printf ("Raspberry Pi - 6-LED Sequence\n") ;
80 printf ("=============================\n") ;
82 printf (" Use the 2 buttons to temporarily speed up the sequence\n") ;
84 wiringPiSetupSys () ; // Not using the Pi's GPIO here
85 drcSetupSerial (GERT_BASE, 20, "/dev/ttyAMA0", 115200) ;
87 for (pin = 0 ; pin < 6 ; ++pin)
88 pinMode (pinMap [pin], OUTPUT) ;
90 pinMode (GERT_BASE + 16, INPUT) ; // Buttons
91 pinMode (GERT_BASE + 17, INPUT) ;
93 pullUpDnControl (GERT_BASE + 16, PUD_UP) ;
94 pullUpDnControl (GERT_BASE + 17, PUD_UP) ;
100 l = data [dataPtr++] ; // LED
101 s = data [dataPtr++] ; // State
102 d = data [dataPtr++] ; // Duration (10ths)
104 if (s == 9) // 9 -> End Marker
110 digitalWrite (pinMap [l], s) ;
111 delay (d * digitalRead (GERT_BASE + 16) * 15 + digitalRead (GERT_BASE + 17) * 20) ;