switch to camelCase to match arduino style
[challenge-bot] / phase0 / phase0.ino
CommitLineData
a77b88c5 1/*
f29767e8 2 This program is free software: you can redistribute it and/or modify
a77b88c5 3 it under the terms of the GNU Affero General Public License as
4 published by the Free Software Foundation, either version 3 of
5 the License, or (at your option) any later version.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU Affero General Public License for more details.
11
12 You should have received a copy of the GNU Affero General Public License
13 along with this program. If not, see <http://www.gnu.org/licenses/>.
14 */
a77b88c5 15int red0 = 12;
16int yellow0 = 11;
17int green0 = 10;
18
19int red1 = 7;
20int yellow1 = 6;
21int green1 = 5;
22
23void setup() {
a77b88c5 24 pinMode(red0, OUTPUT);
25 pinMode(red1, OUTPUT);
26 pinMode(yellow0, OUTPUT);
27 pinMode(yellow1, OUTPUT);
28 pinMode(green0, OUTPUT);
29 pinMode(green1, OUTPUT);
30}
31
c8ce6466 32/*
33 on(pinNumber);
34 turn on pin 'pinNumber'.
35 digitalWrite(pinNumber, HIGH); turns the voltage on for that pin.
36 */
37void on(int pinToTurnOn) {
38 digitalWrite(pinToTurnOn, HIGH);
a77b88c5 39}
40
c8ce6466 41/*
42 off(pinNumber);
43 turn off pin 'pinNumber'.
44 digitalWrite(pinNumber, LOW); turns the voltage off for that pin.
45*/
46void off(int pinToTurnOff) {
47 digitalWrite(pinToTurnOff, LOW);
a77b88c5 48}
49
c8ce6466 50void onsOffs(int* pinsToTurnOn, int numberOfPinsToTurnOn,
51 int* pinsToTurnOff, int numberOfPinsToTurnOff){
52 // generic index used for arrays of pins to turn on or off
53 int index;
54 // turn off pins in pinsToTurnOff
55 for(index = 0; index < numberOfPinsToTurnOff; index++) {
56 off(pinsToTurnOff[index]);
a77b88c5 57 }
c8ce6466 58 // turn on pins in pinsToTurnOn
59 for(index = 0; index < numberOfPinsToTurnOn; index++) {
60 on(pinsToTurnOn[index]);
a77b88c5 61 }
a77b88c5 62}
63
64void loop() {
c8ce6466 65 int redWait = 300;
66 int yellowWait = 800;
67 int greenWait = 1600;
a77b88c5 68
c8ce6466 69 onsOffs((int[]){red0, green1}, 2,
70 (int[]){yellow0, green0, red1, yellow1}, 4);
71 delay(greenWait);
a77b88c5 72
c8ce6466 73 onsOffs((int[]){red0, yellow1}, 2,
74 (int[]){yellow0, green0, red1, green1}, 4);
75 delay(yellowWait);
a77b88c5 76
c8ce6466 77 onsOffs((int[]){red0, red1}, 2,
78 (int[]){yellow0, green0, yellow1, green1}, 4);
79 delay(redWait);
a77b88c5 80
c8ce6466 81 onsOffs((int[]){green0, red1}, 2,
82 (int[]){red0, yellow0, yellow1, green1}, 4);
83 delay(greenWait);
a77b88c5 84
c8ce6466 85 onsOffs((int[]){yellow0, red1}, 2,
86 (int[]){red0, green0, yellow1, green1}, 4);
87 delay(yellowWait);
a77b88c5 88
c8ce6466 89 onsOffs((int[]){red0, red1}, 2,
90 (int[]){yellow0, green0, yellow1, green1}, 4);
91 delay(redWait);
a77b88c5 92}