5
\$\begingroup\$

I'd like to detect two buttons being pressed together with the Arduino LCD shield. Does anyone have example code of handling multiple button events? I need an event when both the Up and Down buttons are pressed together for 2 seconds.

The LCD Shield is the 16*2 HD44780 compatible LCD with WHITE characters & BLUE backlight that has 6 buttons. I got it from www.hotsolder.co.uk.

\$\endgroup\$
2
\$\begingroup\$

It looks like this shield has 5 buttons attached to different value resistors on a single analogue pin. The sixth button is hardwired to reset. Here's the schematic.

alt text http://www.nuelectronics.com/estore/images/nustore/projects/lcd_schematics.jpg

The sample code has a lookup table to convert the ADC values to keys:

int  adc_key_val[5] ={30, 150, 360, 535, 760 };

If you're lucky, you might be able to spot two keys being pressed at the same time as a unique ADC reading.

Try writing a short sketch to print the ADC value to the serial port, then experiment. See if you can find unique ranges of ADC values representing the key combinations you're interested in.

To detect a press for a length of time, use the Arduino millis() function to record the time then compare. This is very similar to debouncing a button.

\$\endgroup\$
2
\$\begingroup\$

Depends how the buttons are wired, is it in a matrix, or is each button individually readable? If it's individual, I don't see what the problem is, just read both buttons, wait until they are both pressed, and then wait two seconds making sure they don't get un-pressed during that time.

If they're wired in a matrix, it may not be able to read both of them at the same time.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy