Using Push Button To Display One Line Of Text

The LCD and Keypad Shield gives you a handy 16-character by 2-line display, 5 buttons and a controllable backlight.
Post Reply
Pete K
Posts: 3
Joined: Thu Aug 29, 2013 10:26 pm

Using Push Button To Display One Line Of Text

Post by Pete K » Thu Aug 29, 2013 10:46 pm

I need to incorporate a one line LCD message into my Arduino program when I push a button once and display it the same amount of time an LED stays lit.
Can anyone help with a simple code? I already know how to connect the LCD to the Arduino and have already written the program for the LED to turn on and off using the delay function. There are seven switches and each will display a different message when I press the appropriate switch.

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Using Push Button To Display One Line Of Text

Post by andrew » Fri Aug 30, 2013 12:19 am

Are you using our LCD Keypad shield or your own circuitry?

Pete K
Posts: 3
Joined: Thu Aug 29, 2013 10:26 pm

Re: Using Push Button To Display One Line Of Text

Post by Pete K » Fri Aug 30, 2013 4:17 pm

It is an LCD that I have in my inventory. There are no buttons only the display. The buttons are on a separate piece of equipment. I need the LCD to display what is being dispensed when each different button is pushed on a prototype dispenser.

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Using Push Button To Display One Line Of Text

Post by andrew » Sat Aug 31, 2013 6:00 am

Just start small. Create a sketch that checks each of your buttons in turn - and if one is pressed then it displays the message on the LCD for a period of time and also turns on the LED for the same period of time.

Pete K
Posts: 3
Joined: Thu Aug 29, 2013 10:26 pm

Re: Using Push Button To Display One Line Of Text

Post by Pete K » Sun Sep 01, 2013 8:44 pm

What I need is the minimum sketch required to display a message. I have found so many while researching my problem I was hoping someone could help me with a basic sketch or point me to one on the net. Getting the LED to turn on is not the problem as I have figured out how to do that AND trip a relay at the same time. I was hoping to find someone that could write a basic sketch for my purpose and help me to incorporate it into mine. Thanks for any help ;)

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Using Push Button To Display One Line Of Text

Post by andrew » Sun Sep 01, 2013 11:28 pm

Then all you need is a quick study of:
http://arduino.cc/en/Tutorial/LiquidCrystal
http://arduino.cc/en/Reference/LiquidCrystal

So when a button is pressed, you need:
// Print a message to the LCD.
lcd.print("hello, world!");

a delay then
lcd.clear();
to clear the screen. Etc.

With respect try to do it yourself, being reliant on others or mashing their code into yours will hold you back at best or drive you crazy at worst :)

Post Reply