Kegerator LCD Display Repeating Text

Hey Guys, this is my first project with Arduino. I built a custom kegerator and it has 4 homebrews on tap, and since everyone’s always asking what is on tap I decided to have arduino help me out. I built a skyline with a 20x4 LCD in it. I have 4 buttons for each tap and have it run so when you push a button it tells you what beers are on tap. My only issue is that when you push a button, it will sometimes repeat the text. I currently have it so it shows the text for a delay of 1500, but even if you just tap the button, it will sometimes repeat the text.

Any help would be really helpful, or any recommendations of how I can write the code to be more efficient.

Thanks!
Code Below:

/*
Kegerator
4 x LED
1 x LCD 20x4
4 x Buttons
A Whole Bunch of Beer Drinking Goodness
*/

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,4);
int button1 = 8;  // Tap 1
int button2 = 9;  // Tap 2
int button3 = 10;  // Tap 3
int button4 = 11;  // Tap 4
int led4 = 4;  //Pin 4 LED behind the skyline 
int led5 = 5;  //Pin 5 LED behind the skyline 
int led6 = 6;  //Pin 6 LED behind the skyline 
int led7 = 7;  //Pin 7 LED behind the skyline 
int sensorPin = 0; 
int val = 0;

void setup() {
  lcd.init();                   // initialize the lcd 
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(button3, INPUT);
  pinMode(button4, INPUT);  
  pinMode(led4, OUTPUT);     
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);     
  pinMode(led7, OUTPUT);
  
// Print a message to the LCD.
  lcd.backlight();
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0); 
  lcd.print("Roof Deck"); 
  lcd.setCursor(0,1); 
  lcd.print("Brewing Company");
  lcd.setCursor(0,3);
  lcd.print("Happy 4th of July"); 
}

void loop() {
  digitalWrite(led4, HIGH);   // turn the LED on 
  digitalWrite(led5, HIGH);   // turn the LED on
  digitalWrite(led6, HIGH);   // turn the LED on 
  digitalWrite(led7, HIGH);   // turn the LED on 
 
     val = digitalRead(button1);
 if (val == HIGH){
     lcd.clear();
     Tap1();
 } else { }
 
      val = digitalRead(button2);
 if (val == HIGH){
     lcd.clear();
     Tap2();
 } else { }
 
      val = digitalRead(button3);
 if (val == HIGH){
     lcd.clear();
     Tap3();
 } else { }
 
      val = digitalRead(button4);
 if (val == HIGH){
     lcd.clear();
     Tap4();
 } else { }
}

void Tap1() 
{
// Print a message to the LCD.
  lcd.backlight();
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Sharky Brown");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("Brown Ale");
  lcd.setCursor(0,2);           // set cursor to column 0, row 0 (the first row)
  lcd.print("5.4% abv");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,3);           // set cursor to column 0, row 1
  lcd.print("Hops: |---X-------|");  
  delay(1500);
  setup();
}

void Tap2() 
{
// Print a message to the LCD.
  lcd.backlight();
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("RedruM Rye");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("Rye Red Ale");
  lcd.setCursor(0,2);           // set cursor to column 0, row 0 (the first row)
  lcd.print("5.6% abv");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,3);           // set cursor to column 0, row 1
  lcd.print("Hops: |------X----|");  
  delay(1500);
  setup();

}

void Tap3() 
{
// Print a message to the LCD.
  lcd.backlight();
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("The Perpetrator");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("India Pale Ale");
  lcd.setCursor(0,2);           // set cursor to column 0, row 0 (the first row)
  lcd.print("6.5% abv");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,3);           // set cursor to column 0, row 1
  lcd.print("Hops: |---------X-|");  
  delay(1500);
  setup();

}

void Tap4() 
{
// Print a message to the LCD.
  lcd.backlight();
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Lucky Number 7");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("Pale Ale");
  lcd.setCursor(0,2);           // set cursor to column 0, row 0 (the first row)
  lcd.print("5.3% abv");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,3);           // set cursor to column 0, row 1
  lcd.print("Hops: |------X----|");  
  delay(1500);
  setup();

}
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(button3, INPUT);
  pinMode(button4, INPUT);

You aren't enabling the internal pullup resistors. This means that you have external pullup or pulldown resistors, right?

     val = digitalRead(button1);
 if (val == HIGH){

With this, you need external pulldown resistors. You do have them, right?

Hey Paul,

Sorry I am not completely familiar with the terminology, but I believe I am using pulldown resistors. Is that where you have resistors completing a different circuit but in line with switches? Please see my schematic below.

Why not dispense with the external pulldown resistors, enable the internal pullup resistors, and switch the code so that LOW == pressed? Fewer components, easier wiring, and it works.

Would that simply be done by removing the resistor circuits from the button and switching each line to read:

     val = digitalRead(button1);
 if (val == LOW){
     lcd.clear();
     Tap1();
 } else { }

Would that simply be done by removing the resistor circuits from the button and switching each line to read

http://www.ladyada.net/learn/arduino/lesson5.html is a good tutorial on switches.

You need to rewire the switches. gnd --> switch --> pin Pressing the switch then grounds the pin (pulling it LOW). Releasing the switch allows the pullup resistor to pull the pin back up to HIGH.

You need to enable the internal pullup. This is done using digitalWrite(pin, HIGH); after declaring the pin an INPUT.

You need to make the code look like what you posted.

I sincerely appreciate all of the help. I will try your suggestion.

Proper Setup?

Works Great! Thanks again!