remove public domain notices
[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
32void on(int led) {
33 digitalWrite(led, HIGH);
34}
35
36void off(int led) {
37 digitalWrite(led, LOW);
38}
39
40void ons_offs(int* ons, int onsc,
41 int* offs, int offsc,
42 int delay_time) {
43 int ii;
44 for(ii = 0; ii < offsc; ii++) {
45 off(offs[ii]);
46 }
47 for(ii = 0; ii < onsc; ii++) {
48 on(ons[ii]);
49 }
50 delay(delay_time);
51}
52
53void loop() {
54 int red_wait = 300;
55 int yellow_wait = 800;
56 int green_wait = 1600;
57
58 ons_offs((int[]){red0, green1}, 2,
59 (int[]){yellow0, green0, red1, yellow1}, 4,
60 green_wait);
61
62 ons_offs((int[]){red0, yellow1}, 2,
63 (int[]){yellow0, green0, red1, green1}, 4,
64 yellow_wait);
65
66 ons_offs((int[]){red0, red1}, 2,
67 (int[]){yellow0, green0, yellow1, green1}, 4,
68 red_wait);
69
70 ons_offs((int[]){green0, red1}, 2,
71 (int[]){red0, yellow0, yellow1, green1}, 4,
72 green_wait);
73
74 ons_offs((int[]){yellow0, red1}, 2,
75 (int[]){red0, green0, yellow1, green1}, 4,
76 yellow_wait);
77
78 ons_offs((int[]){red0, red1}, 2,
79 (int[]){yellow0, green0, yellow1, green1}, 4,
80 red_wait);
81}