arduino crashing everytime on button press

Hi

So my arduino keeps crashing whenever I push one button which I need to be high in order to send a message to my LCD. I cant find any problem with the button or the LCD.

Here is my code.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int buttonPin1 = 7;

void setup() {
  lcd.begin(16, 2);
  lcd.print("LOADING...");
  delay(2000);  //displays for 2 secs
  lcd.clear();  //clears display
  pinMode(buttonPin1, INPUT);
  digitalWrite(buttonPin1, LOW);
}


void loop() {
  int buttonState1 = digitalRead(buttonPin1);

  if (buttonState1 == HIGH) {
    lcd.print("  WELCOME");
    delay(2000);  //displays for 2 secs
    lcd.clear();  //clears display
  }
  if (buttonState1 == LOW) {

  }
}

How have you connected the button? Any chance you are shorting the 5v to ground when you press the buttton?

It is not your code it is the way you have wired up your push button. It looks like from the diagram you have not posted that when you push the button you short out the Arduino's power supply.

Thank you! I put a higher resistor into my circuit and now its working :slight_smile:

yllo:
Thank you! I put a higher resistor into my circuit and now its working :slight_smile:

Which resistor ?
Where is it connected ?
What value did you have and what do you have now ?