2 push button with LCD

I am working on a project for school. I need a 2 push button set up with a LCD.

I want the LCD to say “Selecting Color” until button 1 is pressed. Once button 1 is pressed I want the LCD to read “Next Player”. When button 2 is pressed i need it to say " Great Job"

I also need to know the best way to hook up the switches. I have looked online and there are several different ways to hook them up.

LCD = Pins 12, 11, 5, 4, 3, 2

I will also be hooking up a 3 LED lights that So pins 8,9,10 are taken. ( I have this code written)


This is the code I am trying to work with. Is attached.

Switch Not working.pdf (120 KB)

Please put your code in its own window as seen in other posts. This can be done by placing     [code] and [/code]  around the code. This makes it easier for others to read.

The buttons are wired so that they connect the input pin to gnd when pressed. They also need a pull-up R (10k or internal). Your code is looking for a LOW so this is how it needs to be wired.


I have the input put in pins 6 and 7 and the ground connected on the other side. There is a 10k resistor.

It still isn't working when the buttons are pressed. :o

 #include <LiquidCrystal.h>

int buttonPin6= 18;
int buttonPin7 = 19;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int prevButtonState6;
int prevButtonState7;
void setup()
 pinMode(buttonPin6, INPUT);
 pinMode(buttonPin7, INPUT);
 digitalWrite(buttonPin6, LOW);
 lcd.begin(20, 4);
 lcd.print("SELECTING COLOR");

void loop(){
 int buttonState6 = digitalRead(buttonPin6);
 int buttonState7 = digitalRead(buttonPin7);

 if (buttonState6 == LOW && prevButtonState6== HIGH){
   lcd.print("NEXT PLAYER");
   prevButtonState6 = buttonState6;
 else if(buttonState7 == LOW && prevButtonState7== HIGH){
   lcd.print("GREAT JOB");
   prevButtonState7 = buttonState7;
   prevButtonState6 = buttonState6;
   prevButtonState7 = buttonState7;

If you wire the switches like Weedpharma mentioned, switch to GROUND and input with a 10K external pull up (or better yet, internal pullup set with pinMode(pin, INPUT_PULLUP) I bet it will work better. Or reverse your logic in the sketch to reflect the fact that an unpushed button is LOW and pushed is HIGH.

Confused about the buttons.
So you have a button called "buttonPin6" connected to pin 18.
And a button called "buttonPin7" connected to pin 19.

You can check out my code and schematic http://forum.arduino.cc/index.php?topic=338049.0

It has debounce for the buttons and has a display.

I first had problems making my program compile using the Arduino IDE until I found I had multiple LCD libraries. Some of the libraries are located in C:\Program Files (x86)\Arduino\libraries while on mine some libraries are located in C:\Users\xxxxxx\Documents\Arduino\libraries . I deleted all LCD libraries and installed LCD_I2C Library found on http://playground.arduino.cc/Main/LCDI2C . Good explanation on the libs here also.
Good luck on your project.


Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
And Can you please post a copy of a picture of your project in jpg?

Thanks... Tom..... :slight_smile: