if statement being ignored

I am trying to make a menu with my lcd screen. i am trying to make it so that you can scroll up and down with buttons but the code is ignoring the if statement and no matter what it just does whats in the if statement. (I am talking about the if statement at the very end).

Here is my code

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

const int  en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;
const int i2c_addr = 0x3F;
LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

char Show[5] = {"|/-"};
uint8_t SpecialChar [8]= { 0x00, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00 };

String testing[] = {"testing1", "testing2", "testing3", "testing4", "testing5", "testing6", "testing7", ""};

int down = 2;

void setup() {
  pinMode(down, INPUT);
  
  lcd.begin(16,2);

  lcd.setCursor(0,0);
  lcd.print("Loading Dog");

  delay(1000);

  lcd.setCursor(0,1);
  lcd.print("|");
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Loading Dog");
  lcd.setCursor(0,1);
  lcd.print(char(0));
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Loading Dog");
  lcd.setCursor(0,1);
  lcd.print("-");
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Loading Dog");
  lcd.setCursor(0,1);
  lcd.print("/");
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Loading Dog");
  lcd.setCursor(0,1);
  lcd.print("|");
  delay(1000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Loading Dog");
  delay(1000);
  lcd.clear();
  delay(1000);
  lcd.setCursor(0,0);
  lcd.print(testing[0]);
}

int ButtonDown = 0;

void loop() {
  int i = 0;
  int l = 1;

  ButtonDown = digitalRead(down);
  
  if (ButtonDown == HIGH){
    delay(2000);
    lcd.clear();
    lcd.setCursor(0,0);
    i++;
    lcd.print(testing[i]);
    delay(100);
  }
}

How is your switch wired ?


FYI

the image isn't working but here is the url


Is the ground on the "external power" connected to the Arduino ground?

If your code is always executing the if statement, then ButtonDown is always HIGH.

Using the IDE's serial monitor and printing data to that from your program is an easy way to trouble shoot stuff like this. Simple statements like this:

ButtonDown = digitalRead(down);

Serial.println(ButtonDown);
 
if (ButtonDown == HIGH){

Will print the current ButtonDown to the serial monitor, so you can see what is going on inside the arduino. If you don't know how to use the serial monitor, then look to the adafruit website for tutorials on it.

Most likely, your button is mis-wired, but using the serial monitor, you'll be able to tell when the button is wired correctly.

Randy

no aarg, the ground on the external power is not connected to the arduino ground. and revolt_randy, i took the button off to try a different button but when i took it off i still got reading of it being on, then off, and just going back and forth. could it be something wrong with my arduino uno?

Confusion: why is criticalduck answering questions about gaufdsu's issue? (I see they signed up 10 minutes apart...)

thats my old user name and i wanted to change it but i had to create a new account to do so

criticalduck:
no aarg, the ground on the external power is not connected to the arduino ground

It must be, in order to work.

thanks that did work