LCD 16x2 how to use the buttons

The LCD and Keypad Shield gives you a handy 16-character by 2-line display, 5 buttons and a controllable backlight.
Post Reply
MrDropsy
Posts: 3
Joined: Tue Nov 25, 2014 3:49 am

LCD 16x2 how to use the buttons

Post by MrDropsy » Tue Nov 25, 2014 3:56 am

I purchased the 16x2 LCD with the 5 buttons - up/down/left/right/select

Ive managed to get the text to appear using

#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7);

etc and various print.lcd stuff

now i want to be able to use buttons to do various things

i just read that the buttons have specific voltages which means you know which one was pressed. RIGHT button says 0V doesnt that mean it will always appear to be pushed down? or does the voltage drop down from 5V.

How can i use the difference in voltage for buttons to things with the buttons

for example - say if i wanted to clear the LCD screen of previous text or something

How would i do that?

Or use a button to generate a specific bit of text.

id imagine id use an if statement of some sort or perhaps a switch case.

thanks in advance :D

MrDropsy

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

Re: LCD 16x2 how to use the buttons

Post by andrew » Tue Nov 25, 2014 10:40 am

Please see the LCD Keypad Shield guide:
http://www.freetronics.com/pages/16x2-l ... tart-guide

it gives the analogRead values to expect when the buttons are pushed, and the complex example demonstrates how to have the sketch take actions when buttons are pressed.

However yes, fundamentally you need to read the value from analogue pin zero with analogRead and them make decision based on the value returned.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest