title: Same code but different output in Arduino
body: <p>Recently i'm develop a program by using Arduino UNO. The code i write for two button is totally same but the output different.</p>
  
  <p>Here is the code i write.</p>
  
  <pre><code>const int BUTTON1 = 6;
  const int BUTTON2 = 7;
  String i, j, x;
  
  int ButtonState = 0;
  
  void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    pinMode(BUTTON1, INPUT_PULLUP);
    pinMode(BUTTON2, INPUT_PULLUP);
  }
  
  void loop() {
    if (digitalRead(BUTTON1) == LOW) {
      delay(500);
      i = "1";
      Serial.println(i);
    } 
    if (digitalRead(BUTTON2) == LOW) {
      delay(500);
      j = "2";
      Serial.println(j);
    } 
    else {
      delay(500);
      x = "0";
      Serial.println(x);
    }
  }
  </code></pre>
  
  <p>When i keep pressing the button1, the output is
  1
  0
  1
  0
  1
  0
  1
  0</p>
  
  <p>And when i keep pressing the button2, the ouput is
  2
  2
  2
  2
  2
  2
  2</p>
  
  <p>How can i make the output of button1 same with the output of button2?</p>