Adding buttons to Arduino

I added an LCD to my Arduino Diecimila like this http://arduino.cc/en/uploads/Tutorial/lcd_bb.png

So now i want to add 3 push buttons to control menus and stuff. I am not very good with buttons could somebody give me a link if there is one to how to add buttons.

Is this all I have to do?

I also came across this tutorial but i can't determine which chip he is using?

http://www.avrprojects.net/index.php?option=com_content&view=article&id=65:lcd-interface-board&catid=37:avr-projects&Itemid=57

I built a board for my arduino that I can plug an LCD into and it has buttons as well. See it here: LCD shield with LCD mounted | Here is the LCD shield with th… | Flickr
I use the analog pins in digital mode, turned on the internal pullups and then used the buttons to ground the inputs when the buttons are pushed. It took some time, but it has been a very useful development tool.

Wow that's exactly what i'm looking to try and do! The picture is to small for me to see all of the connections. Did you draw a diagram for yours?

You can find a number of button examples under the Digital I/O section of this page: http://arduino.cc/en/Tutorial/HomePage.

Thanks, but those examples only use one button to control an LED. I want to be able to control menus and programs.

Similar to this one: http://www.nuelectronics.com/estore/images/nustore/lcd_shield_1.jpg

If anyone can tell me where i might find a diagram or anything that is similar to that I will be forever grateful.

The button would be wired the same regardless of the example. You are going to use digital inputs to determine what to do with the menu. So your going to ask:

If there is a signal on this pin, then move the menu up one.

So the diagram in http://arduino.cc/en/Tutorial/Button would work, you would just leave out the led and the code for the led. I have no idea how the coding for the menu works, but sticking with the button project the basic program would look something like:

int upButton=0;

void setup()
{
     pinMode(2,INPUT);
}

void loop()
{
     upButton=-digitalRead(2)+1;  //Ok, so when I was taught programming 0 meant off and
     //1 meant on, so I have to reverse this or I go nuts!
     //all this does is switch around 0 and 1...
     //so just to show the math:  -0+1=1 and -1+1=0

     if(upButton==1)//so now if the button is pressed, do stuff...
     {
          //Menu Move Up Code
     }
}

So any of the button examples/tutorials on the thread can be used.

The entire code is not listed here, so I put some snippets in for you.

I did something like this:

int backBtn = 14; //These are the input buttons
int incBtn = 15;
int decBtn = 17;
int nextBtn = 18;
int escapeBtn = 16;

void setup()
{
pinMode(backBtn,INPUT); //set pin as input
digitalWrite(backBtn, HIGH); //turn on the internal pull-up
pinMode(incBtn,INPUT);
digitalWrite(incBtn, HIGH); //turn on the internal pull-up

ETC.

then when I read buttons:

void readBtns()
{
back = digitalRead(backBtn); //Read the value of backBtn
next = digitalRead(nextBtn); //Read the value of nextBtn
escape = digitalRead(escape_Button); //Read the value of escape_Button
inc = digitalRead(incBtn); //Read the value of incBtn
dec = digitalRead(decBtn); //Read the value of decBtn
delay(debounce); //Wait a short time

The buttons are tied to ground on one side and to the input pin on the other side. In the setup, I defined the pin as an input and then set the pull up with digitalWrite to HIGH.

Hopefully, this makes a bit more sense.

If you are willing to sacrifice a bit of codespace and some resistors then you can do it with one analogue input.

Shamelessly pillaged from http://www.robotshop.us/dfrobot-lcd-keypad-shield-arduino.html and every video camera wired controller since the beginning of time.

//example use of LCD4Bit_mod library

#include <LCD4Bit_mod.h>
//create object to control an LCD.
//number of lines in display=1
LCD4Bit_mod lcd = LCD4Bit_mod(2);

//Key message
char msgs[5][15] = {"Right Key OK ",
"Up Key OK ",
"Down Key OK ",
"Left Key OK ",
"Select Key OK" };
int adc_key_val[5] ={30, 150, 360, 535, 760 };
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;

void setup() {
pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat

lcd.init();
//optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
//lcd.commandWrite(0x0F);//cursor on, display on, blink on. (nasty!)
lcd.clear();
lcd.printIn("KEYPAD testing... pressing");

}

void loop() {

adc_key_in = analogRead(0); // read the value from the sensor
digitalWrite(13, HIGH);
key = get_key(adc_key_in); // convert into key press

if (key != oldkey) // if keypress is detected
{
delay(50); // wait for debounce time
adc_key_in = analogRead(0); // read the value from the sensor
key = get_key(adc_key_in); // convert into key press
if (key != oldkey)
{
oldkey = key;
if (key >=0){
lcd.cursorTo(2, 0); //line=2, x=0
lcd.printIn(msgs[key]);
}
}
}

//delay(1000);
digitalWrite(13, LOW);

}

// Convert ADC value to key number
int get_key(unsigned int input)
{
int k;

for (k = 0; k < NUM_KEYS; k++)
{
if (input < adc_key_val[k])
{

return k;
}
}

if (k >= NUM_KEYS)
k = -1; // No valid key pressed

return k;
}