I have an Arduino connected with 2 buttons. When one is pressed it should display Begin Tracking and when the other is pressed it should display End Tracking. I have the first button working but the second gives me "und Tracking" and when I put a space it displays "pEnd Tracking". Any ideas? Here is my code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int buttonPin = 10; // the number of the pushbutton pin
const int buttonPin1 = 6;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int buttonState1 =0;
void setup() {
Serial.begin(9600);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(buttonPin, INPUT);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("TEAM MEJR");
delay(1000);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
buttonState1 = digitalRead(buttonPin1);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
lcd.setCursor(0,0);
lcd.print("Begin Tracking");
delay(100);
}
else if(buttonState1 == HIGH){
// turn LED off:
lcd.setCursor(0,0);
lcd.print("End Tracking");
delay(100);
}
else{
// digitalWrite(ledPin, LOW);
lcd.clear();
}
}