1
2
3
4
5
6
7#include <EEPROM.h>
8#include <Wire.h>
9#include <LiquidCrystal_I2C.h>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28int up = 2;
29int down = 3;
30int outputA0 = 14;
31int outputA1 = 15;
32int outputA2 = 16;
33
34
35int page_counter;
36
37
38bool current_up = LOW;
39bool last_up=LOW;
40bool last_down = LOW;
41bool current_down = LOW;
42
43void setup() {
44
45checkpagecounterState();
46
47pinMode(up,INPUT);
48pinMode(down,INPUT);
49pinMode(outputA0,OUTPUT);
50pinMode(outputA1,OUTPUT);
51pinMode(outputA2,OUTPUT);
52
53
54
55LiquidCrystal_I2C lcd(0x27, 16, 2);
56lcd.init();
57lcd.backlight();
58lcd.clear();
59}
60
61
62boolean debounce(boolean last, int pin)
63{
64boolean current = digitalRead(pin);
65if (last != current)
66{
67delay(40);
68current = digitalRead(pin);
69}
70return current;
71}
72
73void loop() {
74
75
76LiquidCrystal_I2C lcd(0x27, 20, 4);
77 lcd.backlight();
78 lcd.setCursor(0,0);
79 lcd.print("Gxxxx Loc xxxxxx");
80
81current_up = debounce(last_up, up);
82current_down = debounce(last_down, down);
83
84
85
86
87
88 if (last_up== LOW && current_up == HIGH){
89 lcd.clear();
90 if(page_counter <7){
91 page_counter= page_counter +1;
92
93 }
94 else{
95 page_counter= 1;
96 }
97 }
98
99 last_up = current_up;
100
101
102 if (last_down== LOW && current_down == HIGH){
103 lcd.clear();
104 if(page_counter >1){
105 page_counter= page_counter -1;
106
107 }
108 else{
109 page_counter= 7;
110 }
111 }
112
113 last_down = current_down;
114
115
116EEPROM.update(0, page_counter);
117
118
119
120
121
122
123 switch (page_counter) {
124
125 case 1:{
126 digitalWrite(outputA0,LOW);
127 digitalWrite(outputA1,LOW);
128 digitalWrite(outputA2,LOW);
129 lcd.setCursor(0,1);
130 lcd.print("A 6m/2m/70c Vert");
131
132 }
133 break;
134
135
136 case 2: {
137 digitalWrite(outputA0,HIGH);
138 digitalWrite(outputA1,LOW);
139 digitalWrite(outputA2,LOW);
140 lcd.setCursor(0,1);
141 lcd.print("B 144MHz 2m Horz");
142
143 }
144 break;
145
146 case 3: {
147 digitalWrite(outputA0,LOW);
148 digitalWrite(outputA1,HIGH);
149 digitalWrite(outputA2,LOW);
150 lcd.setCursor(0,1);
151 lcd.print("C 50MHz 6m Horz ");
152
153 }
154 break;
155
156 case 4: {
157 digitalWrite(outputA0,HIGH);
158 digitalWrite(outputA1,HIGH);
159 digitalWrite(outputA2,LOW);
160 lcd.setCursor(0,1);
161 lcd.print(" ");
162
163 }
164 break;
165
166 case 5: {
167 digitalWrite(outputA0,LOW);
168 digitalWrite(outputA1,LOW);
169 digitalWrite(outputA2,HIGH);
170 lcd.setCursor(0,1);
171 lcd.print(" ");
172
173 }
174 break;
175
176 case 6: {
177 digitalWrite(outputA0,HIGH);
178 digitalWrite(outputA1,LOW);
179 digitalWrite(outputA2,HIGH);
180 lcd.setCursor(0,1);
181 lcd.print(" ");
182
183 }
184 break;
185
186 case 7: {
187 digitalWrite(outputA0,LOW);
188 digitalWrite(outputA1,HIGH);
189 digitalWrite(outputA2,HIGH);
190 lcd.setCursor(0,1);
191 lcd.print("All relays off ");
192
193 }
194 break;
195
196 }
197
198}
199
200void checkpagecounterState()
201{
202 page_counter = EEPROM.read(0);
203if (page_counter <1)return 1;
204if (page_counter >7) return 1;
205
206}
207
208
209
210
211