Arduino Simple LCD Menu

Introduction

In this article, I will show you a simple LCD Menu implementation I am working on.

In here, we use an Arduino Uno board, a 16×2 LCD for the display, and some tactile buttons for controlling the menu.

The menu is implemented using state machines for the menu navigation. A button debouncing is implemented to prevent unknown button actions.

So here it, feel free to modify it to your liking.

Circuit Diagram

Video Demonstration

Source Code

  1/*
  2 *  Simple 16x2 LCD Menu Implementation 
  3 *    - this uses a finite state machine
  4 *    - a button debouncing is also implemented to prevent unknown button action
  5 *  Please feel free to modify this to your liking, but please leave this comment as credit  
  6 *  
  7 *  Author: George Bantique
  8 *          @TechToTinker
  9 *          July 18, 2020 *   
 10 */
 11
 12#include "LiquidCrystal.h"
 13
 14LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
 15
 16#define button_B    A0
 17#define button_D    A1
 18#define button_U    A2
 19#define button_E    A3
 20
 21#define ONBOARD_LED 13
 22
 23#define DEFAULT_DELAY 300
 24
 25char buttonPressed = '0';
 26
 27byte menuLevel = 0;     // Level 0: no menu display, display anything you like
 28                        // Level 1: display main menu
 29                        // Level 2: display sub menu
 30
 31byte menu = 1;
 32byte sub = 1;
 33
 34unsigned long relay_val_1 = 0;
 35unsigned long relay_val_2 = 0;
 36unsigned long relay_val_3 = 0;
 37
 38bool LED_STATE = false;
 39
 40bool currState_B = HIGH;
 41bool currState_D = HIGH;
 42bool currState_U = HIGH;
 43bool currState_E = HIGH;
 44          
 45bool prevState_B = HIGH; 
 46bool prevState_D = HIGH; 
 47bool prevState_U = HIGH; 
 48bool prevState_E = HIGH; 
 49
 50unsigned long prevTime_B = 0;
 51unsigned long prevTime_D = 0;
 52unsigned long prevTime_U = 0;
 53unsigned long prevTime_E = 0;
 54
 55unsigned long waitTime_B = 50;
 56unsigned long waitTime_D = 50;
 57unsigned long waitTime_U = 50;
 58unsigned long waitTime_E = 50;
 59
 60
 61void setup() {
 62  lcd.begin(16,2);
 63
 64  Serial.begin(9600);
 65
 66  pinMode(button_B, INPUT_PULLUP);
 67  pinMode(button_D, INPUT_PULLUP);
 68  pinMode(button_U, INPUT_PULLUP);
 69  pinMode(button_E, INPUT_PULLUP);
 70
 71  pinMode(A4,INPUT);
 72
 73  pinMode(ONBOARD_LED, OUTPUT);
 74  digitalWrite(ONBOARD_LED, LED_STATE);
 75  
 76  showHomeScreen();
 77}
 78
 79void loop() {
 80
 81  checkButton();
 82
 83  // You can do other things here below
 84}
 85
 86void checkButton() {
 87  // Button Debouncing
 88  bool currRead_B = digitalRead(button_B);
 89  bool currRead_D = digitalRead(button_D);
 90  bool currRead_U = digitalRead(button_U);
 91  bool currRead_E = digitalRead(button_E);
 92  if (currRead_B != prevState_B) {
 93    prevTime_B = millis();
 94  }
 95  if (currRead_D != prevState_D) {
 96    prevTime_D = millis();
 97  }
 98  if (currRead_U != prevState_U) {
 99    prevTime_U = millis();
100  }
101  if (currRead_E != prevState_E) {
102    prevTime_E = millis();
103  }
104  if ((millis() - prevTime_B) > waitTime_B) {
105    if (currRead_B != currState_B) {
106      currState_B = currRead_B;
107      if (currState_B == LOW) {
108        buttonPressed = 'B';
109      } 
110    }
111  } else buttonPressed = '0';
112  if ((millis() - prevTime_D) > waitTime_D) {
113    if (currRead_D != currState_D) {
114      currState_D = currRead_D;
115      if (currState_D == LOW) {
116        buttonPressed = 'D';
117      } 
118    }
119  } else buttonPressed = '0';
120  if ((millis() - prevTime_U) > waitTime_U) {
121    if (currRead_U != currState_U) {
122      currState_U = currRead_U;
123      if (currState_U == LOW) {
124        buttonPressed = 'U';
125      } else {
126        //buttonPressed = '0';
127      }
128    }
129  } else buttonPressed = '0';
130  if ((millis() - prevTime_E) > waitTime_E) {
131    if (currRead_E != currState_E) {
132      currState_E = currRead_E;
133      if (currState_E == LOW) {
134        buttonPressed = 'E';
135      } 
136    }
137  } else buttonPressed = '0';
138
139  prevState_B = currRead_B;
140  prevState_D = currRead_D;
141  prevState_U = currRead_U;
142  prevState_E = currRead_E;
143
144  processButton(buttonPressed);
145}
146
147void processButton(char buttonPressed) {
148  switch(menuLevel) {
149    case 0: // Level 0
150      switch ( buttonPressed ) {
151        case 'E': // Enter
152          menuLevel = 1;
153          menu = 1;
154          updateMenu();
155          delay(DEFAULT_DELAY);
156          break;
157        case 'U': // Up
158          break;
159        case 'D': // Down
160          break;
161        case 'B': // Back
162          break;
163        default:
164          break;
165      }
166      break;
167    case 1: // Level 1, main menu
168      switch ( buttonPressed ) {
169        case 'E': // Enter
170          updateSub();
171          menuLevel = 2;  // go to sub menu
172          updateSub();
173          delay(DEFAULT_DELAY);
174          break;
175        case 'U': // Up
176          menu++;
177          updateMenu();
178          delay(DEFAULT_DELAY);
179          break;
180        case 'D': // Down
181          menu--;
182          updateMenu();
183          delay(DEFAULT_DELAY);
184          break;
185        case 'B': // Back
186          menuLevel = 0;  // hide menu, go back to level 0
187          showHomeScreen();
188          delay(DEFAULT_DELAY);
189          break;
190        default:
191          break;
192      } 
193      break;
194    case 2: // Level 2, sub menu
195      switch ( buttonPressed ) {
196        case 'E': 
197          menuLevel = 1;
198          updateMenu();
199          delay(DEFAULT_DELAY);
200          break;
201        case 'U': // U
202          if (menu == 1) {
203            if (relay_val_1 < 3600000) {  // 1 hour max
204              relay_val_1 = relay_val_1 + 1;
205            } else {
206              relay_val_1 = 3600000;
207            }
208          } else if (menu == 2) {       
209            if (relay_val_2 < 3600000) {  // 1 hour max
210              relay_val_2 = relay_val_2 + 1;
211            } else {
212              relay_val_2 = 3600000;
213            }
214          } else if (menu == 3) {
215            if (relay_val_3 < 3600000) {  // 1 hour max  
216              relay_val_3 = relay_val_3 + 1;
217            } else {
218              relay_val_3 = 3600000;
219            }
220          }
221          updateSub();
222          delay(DEFAULT_DELAY);
223          break;
224        case 'D': // D
225          if (menu == 1) {
226            if (relay_val_1 == 0) {
227              relay_val_1 = 0;
228            } else {
229              relay_val_1 = relay_val_1 - 1;
230            }
231          } else if (menu == 2) {
232            if (relay_val_2 == 0) {
233              relay_val_2 = 0;
234            } else {
235              relay_val_2 = relay_val_2 - 1;
236            }
237          } else if (menu == 3) {
238            if (relay_val_3 == 0) {
239              relay_val_3 = 0;
240            } else {
241              relay_val_3 = relay_val_3 - 1;
242            }
243          }
244          updateSub();
245          delay(DEFAULT_DELAY);
246          break;
247        case 'B': // L
248          menuLevel = 1;  // go back to main menu
249          updateMenu();
250          delay(DEFAULT_DELAY);
251          break;
252        default:  
253          break;
254      } 
255      break;
256    case 3: // Level 3, sub menu of sub menu
257    
258      break;
259    default:
260      break;
261  }
262}
263
264void updateMenu() {
265  switch (menu) {
266    case 0:
267      menu = 1;
268      break;
269    case 1:
270      lcd.clear();
271      lcd.print(">Relay 1: ");
272      lcd.print(relay_val_1);
273      lcd.setCursor(0, 1);
274      lcd.print(" Relay 2 ");
275      break;
276    case 2:
277      lcd.clear();
278      lcd.print(" Relay 1 ");
279      lcd.setCursor(0, 1);
280      lcd.print(">Relay 2: ");
281      lcd.print(relay_val_2);
282      break;
283    case 3:
284      lcd.clear();
285      lcd.print(">Relay 3: ");
286      lcd.print(relay_val_3);
287      lcd.setCursor(0, 1);
288      lcd.print("             ");
289      break;
290    case 4:
291      menu = 3;
292      break;
293  }
294}
295
296void updateSub() {
297  switch (menu) {
298    case 0:
299      break;
300    case 1:
301      lcd.clear();
302      lcd.print(" Relay 1:");
303      lcd.setCursor(0, 1);
304      lcd.print("  Val 1 = ");
305      lcd.print(relay_val_1);
306      break;
307    case 2:
308      lcd.clear();
309      lcd.print(" Relay 2:");
310      lcd.setCursor(0, 1);
311      lcd.print("  Val 2 = ");
312      lcd.print(relay_val_2);
313      break;
314    case 3:
315      lcd.clear();
316      lcd.print(" Relay 3:");
317      lcd.setCursor(0, 1);
318      lcd.print("  Val 3 = ");
319      lcd.print(relay_val_3);
320      break;
321    case 4:
322      menu = 3;
323      break;
324  }
325}
326
327void showHomeScreen() {
328  lcd.clear();
329  lcd.println("  TechToTinker  ");
330  lcd.setCursor(0,1);
331  lcd.println("  - R for menu  ");
332}
  1/*
  2/*
  3 *  Multi-level 16x2 LCD Menu Implementation 
  4 *    - this is the same as the Simple 16x2 LCD Menu Implementation but with additional levels
  5 *    - this uses a finite state machine
  6 *    - a button debouncing is also implemented to prevent unknown button action
  7 *  Please feel free to modify this to your liking, but please leave this comment as credit  
  8 *  
  9 *  Author: George Bantique
 10 *          @TechToTinker
 11 *          July 18, 2020 *   
 12 */
 13
 14#include "LiquidCrystal.h"
 15
 16LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
 17
 18#define button_B    A0
 19#define button_D    A1
 20#define button_U    A2
 21#define button_E    A3
 22
 23#define ONBOARD_LED 13
 24
 25#define DEFAULT_DELAY 300
 26
 27
 28char buttonPressed = '0';
 29
 30byte menuLevel = 0;     // Level 0: no menu display, display anything you like
 31                        // Level 1: display main menu
 32                        // Level 2: display sub menu
 33                        // Level 3: display sub menu of sub menu
 34
 35byte menu = 1;
 36byte sub = 1;
 37
 38unsigned long relay_val_1 = 0;
 39unsigned long relay_val_2 = 0;
 40unsigned long relay_val_3 = 0;
 41
 42bool LED_STATE = false;
 43
 44bool currState_B = HIGH;
 45bool currState_D = HIGH;
 46bool currState_U = HIGH;
 47bool currState_E = HIGH;
 48          
 49bool prevState_B = HIGH; 
 50bool prevState_D = HIGH; 
 51bool prevState_U = HIGH; 
 52bool prevState_E = HIGH; 
 53
 54unsigned long prevTime_B = 0;
 55unsigned long prevTime_D = 0;
 56unsigned long prevTime_U = 0;
 57unsigned long prevTime_E = 0;
 58
 59unsigned long waitTime_B = 50;
 60unsigned long waitTime_D = 50;
 61unsigned long waitTime_U = 50;
 62unsigned long waitTime_E = 50;
 63
 64byte charUp[8] = {
 65        B00100,
 66        B01110,
 67        B11111,
 68        B00000,
 69        B00000,
 70        B00000,
 71        B00000,
 72        B00000
 73};
 74byte charDown[8] = {
 75        B00000,
 76        B00000,
 77        B00000,
 78        B00000,
 79        B00000,
 80        B11111,
 81        B01110,
 82        B00100
 83};
 84byte charUpDown[8] = {
 85        B00100,
 86        B01110,
 87        B11111,
 88        B00000,
 89        B00000,
 90        B11111,
 91        B01110,
 92        B00100
 93};
 94
 95
 96void setup() {
 97  lcd.begin(16,2);
 98  lcd.createChar(0, charUp);
 99  lcd.createChar(1, charDown);
100  lcd.createChar(2, charUpDown);
101  
102  Serial.begin(9600);
103
104  pinMode(button_B, INPUT_PULLUP);
105  pinMode(button_D, INPUT_PULLUP);
106  pinMode(button_U, INPUT_PULLUP);
107  pinMode(button_E, INPUT_PULLUP);
108
109  pinMode(A4,INPUT);
110
111  pinMode(ONBOARD_LED, OUTPUT);
112  digitalWrite(ONBOARD_LED, LED_STATE);
113  
114  updateLevel_0();
115}
116
117void loop() {
118
119  checkButton();
120
121  // You can do other things here below
122
123  
124}
125
126void checkButton() {
127
128  // Button Debouncing
129  bool currRead_B = digitalRead(button_B);
130  bool currRead_D = digitalRead(button_D);
131  bool currRead_U = digitalRead(button_U);
132  bool currRead_E = digitalRead(button_E);
133
134  if (currRead_B != prevState_B) {
135    prevTime_B = millis();
136  }
137  if (currRead_D != prevState_D) {
138    prevTime_D = millis();
139  }
140  if (currRead_U != prevState_U) {
141    prevTime_U = millis();
142  }
143  if (currRead_E != prevState_E) {
144    prevTime_E = millis();
145  }
146
147  if ((millis() - prevTime_B) > waitTime_B) {
148    if (currRead_B != currState_B) {
149      currState_B = currRead_B;
150      if (currState_B == LOW) {
151        buttonPressed = 'B';
152      } 
153    }
154  } else buttonPressed = '0';
155  if ((millis() - prevTime_D) > waitTime_D) {
156    if (currRead_D != currState_D) {
157      currState_D = currRead_D;
158      if (currState_D == LOW) {
159        buttonPressed = 'D';
160      } 
161    }
162  } else buttonPressed = '0';
163  if ((millis() - prevTime_U) > waitTime_U) {
164    if (currRead_U != currState_U) {
165      currState_U = currRead_U;
166      if (currState_U == LOW) {
167        buttonPressed = 'U';
168      } else {
169        //buttonPressed = '0';
170      }
171    }
172  } else buttonPressed = '0';
173  if ((millis() - prevTime_E) > waitTime_E) {
174    if (currRead_E != currState_E) {
175      currState_E = currRead_E;
176      if (currState_E == LOW) {
177        buttonPressed = 'E';
178      } 
179    }
180  } else buttonPressed = '0';
181  prevState_B = currRead_B;
182  prevState_D = currRead_D;
183  prevState_U = currRead_U;
184  prevState_E = currRead_E;
185  processButton(buttonPressed);
186}
187
188void processButton(char buttonPressed) {
189  switch(menuLevel) {
190    case 0:                     // Level 0, home screen
191      switch ( buttonPressed ) {
192        case 'E':               // Enter
193          menu = 1;
194          menuLevel = 1;        // go to main menu
195          updateLevel_1();      // show main menu
196          delay(DEFAULT_DELAY);
197          break;
198        case 'U': // Up
199          break;
200        case 'D': // Down
201          break;
202        case 'B': // Back
203          menuLevel = 0;        // go to home screen
204          updateLevel_0();      // show home screen
205          delay(DEFAULT_DELAY);
206          break;
207        default:
208          break;
209      }
210      break;
211    case 1:                     // Level 1, main menu
212      switch ( buttonPressed ) {
213        case 'E':               // Enter
214          sub = 1;
215          menuLevel = 2;        // go to sub menu
216          updateLevel_2();      // show sub menu
217          delay(DEFAULT_DELAY);
218          break;
219        case 'U':               // Up
220          menu++;
221          updateLevel_1();      // show main menu
222          delay(DEFAULT_DELAY);
223          break;
224        case 'D':               // Down
225          menu--;
226          updateLevel_1();      // show main menu
227          delay(DEFAULT_DELAY);
228          break;
229        case 'B': // Back
230          menuLevel = 0;        // hide menu, go back to level 0
231          updateLevel_0();      // show home screen
232          delay(DEFAULT_DELAY);
233          break;
234        default:
235          break;
236      } 
237      break;
238    case 2:                     // Level 2, sub menu
239      switch ( buttonPressed ) {
240        case 'E':               // Enter
241          if (sub == 2) {       // Jump to sub menu of sub menu only when edit is necessary
242            menuLevel = 3;        // go to sub menu of sub menu
243            updateLevel_3();      // show sub menu of sub menu
244          } else if (sub == 3) {
245            executeAction();
246            delay(1000);
247            menuLevel = 2;        // go to sub menu
248            updateLevel_2();      // show sub menu
249          }
250          delay(DEFAULT_DELAY);
251          break;
252        case 'U':               // Up
253          sub++;
254          updateLevel_2();
255          delay(DEFAULT_DELAY);
256          break;
257        case 'D':               // Down
258          sub--;
259          updateLevel_2();      // show main menu
260          delay(DEFAULT_DELAY);
261          break;
262        case 'B':               // Back
263          menuLevel = 1;        // go back to level 1
264          updateLevel_1();      // show main menu
265          delay(DEFAULT_DELAY);
266          break;
267        default:
268          break;
269      } 
270      break;
271    case 3:                     // Level 3, sub menu of sub menu
272      switch ( buttonPressed ) {
273        case 'E':               // Enter
274          menuLevel = 2;        // go back to level 2
275          updateLevel_2();      // show sub menu
276          delay(DEFAULT_DELAY);
277          break;
278        case 'U':               // Up
279          if (sub == 2) {       // edit value
280            if        (menu == 1) {
281              if (relay_val_1 < 3600000) {  // 1 hour max
282                relay_val_1 = relay_val_1 + 1;
283              } else {
284                relay_val_1 = 3600000;
285              }
286            } else if (menu == 2) {       
287              if (relay_val_2 < 3600000) {  // 1 hour max
288                relay_val_2 = relay_val_2 + 1;
289              } else {
290                relay_val_2 = 3600000;
291              }
292            } else if (menu == 3) {
293              if (relay_val_3 < 3600000) {  // 1 hour max  
294                relay_val_3 = relay_val_3 + 1;
295              } else {
296                relay_val_3 = 3600000;
297              }
298            }
299          }
300          updateLevel_3();      // show sub menu
301          delay(DEFAULT_DELAY);
302          break;
303        case 'D':               // Down
304          if (sub == 2) {       // edit value
305            if        (menu == 1) {
306              if (relay_val_1 == 0) {
307                relay_val_1 = 0;
308              } else {
309                relay_val_1 = relay_val_1 - 1;
310              }
311            } else if (menu == 2) {
312              if (relay_val_2 == 0) {
313                relay_val_2 = 0;
314              } else {
315                relay_val_2 = relay_val_2 - 1;
316              }
317            } else if (menu == 3) {
318              if (relay_val_3 == 0) {
319                relay_val_3 = 0;
320              } else {
321                relay_val_3 = relay_val_3 - 1;
322              }
323            }
324          }
325          updateLevel_3();      // show sub menu
326          delay(DEFAULT_DELAY);
327          break;
328        case 'B':               // Back
329          menuLevel = 2;        // go back to main menu
330          updateLevel_2();      // show main menu
331          delay(DEFAULT_DELAY);
332          break;
333        default:  
334          break;
335      } 
336      break;
337    default:
338      break;
339  }
340}
341
342void updateLevel_0() {
343  lcd.clear();
344  lcd.println("  TechToTinker  ");
345  lcd.setCursor(0,1);
346  lcd.println("  - R for menu  ");
347}
348
349void updateLevel_1 () {
350  switch (menu) {
351    case 0:
352      menu = 1;
353      break;
354    case 1:
355      lcd.clear();
356      lcd.print(">Relay 1: ");
357      lcd.print(relay_val_1);
358      lcd.setCursor(0, 1);
359      lcd.print(" Relay 2 ");
360      lcd.setCursor(15,1);
361      lcd.write((byte)1);     // down arrow
362      break;
363    case 2:
364      lcd.clear();
365      lcd.print(" Relay 1 ");
366      lcd.setCursor(0, 1);
367      lcd.print(">Relay 2: ");
368      lcd.print(relay_val_2);
369      lcd.setCursor(15,1);
370      lcd.write((byte)2);     // up and down arrow
371      break;
372    case 3:
373      lcd.clear();
374      lcd.print(">Relay 3: ");
375      lcd.print(relay_val_3);
376      lcd.setCursor(0, 1);
377      lcd.print("             ");
378      lcd.setCursor(15,1);
379      lcd.write((byte)0);     // up arrow
380      break;
381    case 4:
382      menu = 3;
383      break;
384  }
385}
386
387void updateLevel_2 () {
388  switch (menu) {
389    case 0:
390      break;
391    case 1:                                 // Relay 1
392      switch (sub) {
393        case 0:
394          break;
395        case 1:
396          lcd.clear();
397          lcd.print(" Relay 1:");
398          lcd.setCursor(0, 1);
399          lcd.print("  Val 1 = ");
400          lcd.print(relay_val_1);
401          lcd.setCursor(15,1);
402          lcd.write((byte)1);     // down arrow
403          break;
404        case 2:
405          lcd.clear();
406          lcd.print(" Relay 1:");
407          lcd.setCursor(0, 1);
408          lcd.print("  Edit Val 1   ");
409          lcd.print(relay_val_1);
410          lcd.setCursor(15,1);
411          lcd.write((byte)2);     // up and down arrow
412          break;
413        case 3:
414          lcd.clear();
415          lcd.print(" Relay 1:");
416          lcd.setCursor(0, 1);
417          lcd.print("  Execute Val 1");
418          lcd.setCursor(15,1);
419          lcd.write((byte)0);     // up arrow
420          break;
421        default:
422          break;
423      }
424      break;
425    case 2:                                 // Relay 2
426      switch (sub) {
427        case 0:
428          break;
429        case 1:
430          lcd.clear();
431          lcd.print(" Relay 2:");
432          lcd.setCursor(0, 1);
433          lcd.print("  Val 2 = ");
434          lcd.print(relay_val_2);
435          lcd.setCursor(15,1);
436          lcd.write((byte)1);     // down arrow
437          break;
438        case 2:
439          lcd.clear();
440          lcd.print(" Relay 2:");
441          lcd.setCursor(0, 1);
442          lcd.print("  Edit Val 2   ");
443          lcd.setCursor(15,1);
444          lcd.write((byte)2);     // up and down arrow
445          break;
446        case 3:
447          lcd.clear();
448          lcd.print(" Relay 2:");
449          lcd.setCursor(0, 1);
450          lcd.print("  Execute Val 2");
451          lcd.setCursor(15,1);
452          lcd.write((byte)0);     // up arrow
453          break;
454        default:
455          break;
456      }
457      break;
458    case 3:                               // Relay 3
459      switch (sub) {
460        case 0:
461          break;
462        case 1:
463          lcd.clear();
464          lcd.print(" Relay 3:");
465          lcd.setCursor(0, 1);
466          lcd.print("  Val 3 = ");
467          lcd.print(relay_val_3);
468          lcd.setCursor(15,1);
469          lcd.write((byte)1);     // down arrow
470          break;
471        case 2:
472          lcd.clear();
473          lcd.print(" Relay 3:");
474          lcd.setCursor(0, 1);
475          lcd.print("  Edit Val 3   ");
476          lcd.setCursor(15,1);
477          lcd.write((byte)2);     // up and down arrow
478          break;
479        case 3:
480          lcd.clear();
481          lcd.print(" Relay 3:");
482          lcd.setCursor(0, 1);
483          lcd.print("  Execute Val 3");
484          lcd.setCursor(15,1);
485          lcd.write((byte)0);     // up arrow
486          break;
487        default:
488          break;
489      }
490      break;
491    case 4:
492      sub = 3;
493      break;
494  }
495}
496
497void updateLevel_3 () {
498  switch (menu) {
499    case 0:
500      break;
501    case 1:
502      lcd.clear();
503      lcd.print(" Relay 1:");
504      lcd.setCursor(0, 1);
505      lcd.print("  Val 1 = ");
506      lcd.print(relay_val_1);
507      break;
508    case 2:
509      lcd.clear();
510      lcd.print(" Relay 2:");
511      lcd.setCursor(0, 1);
512      lcd.print("  Val 2 = ");
513      lcd.print(relay_val_2);
514      break;
515    case 3:
516      lcd.clear();
517      lcd.print(" Relay 3:");
518      lcd.setCursor(0, 1);
519      lcd.print("  Val 3 = ");
520      lcd.print(relay_val_3);
521      break;
522    case 4:
523      sub = 3;
524      break;
525  }
526}
527
528void executeAction () {
529  switch (menu) {
530    case 0:
531      break;
532    case 1:
533      lcd.clear();
534      lcd.print(" Executing # 1");
535      break;
536    case 2:
537      lcd.clear();
538      lcd.print(" Executing # 2");
539      break;
540    case 3:
541      lcd.clear();
542      lcd.print(" Executing # 3");
543      break;
544    case 4:
545      sub = 3;
546      break;
547  }
548}

Call To Action

If you found this tutorial as helpful, please Like and Share this to your friends. Don’t forget to Subscribe. Click this to Subscribe to TechToTinker Youtube channel.

Thank you and have a good day.



Posts in this series



1 comment

GitHub-flavored Markdown & a sane subset of HTML is supported.