lcd keypad shield + intterrupts help

hey

so i goth this keypad lcd shield with have 5 buttons witch i wut like to make an intterrupt function for becouse my main loop is kinda long and keeps a lot off othere stuff and varibals updated but alle the 5 buttons from the shield lands on analog pin 0 witch aint a intterrupts enabled pin is there any work arounds ??

link to the keypad shield
http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)

is there any work arounds ??

Re-write your code so it isn't blocking.

the problem is that the shield is realying the buttons click to analog pin 0 and the uno intterrupt is to digital pin 2 and 3 as fare as i understand.

how wut you tackle this ??

how wut you tackle this ??

I'd write the code so that it didn't need interrupts.

raschemmel:
There's a really neat thing out now. You should try it . It's called GOOGLE. Boy is it slick. I just type in "Arduino interrupts" and look what I get !"
Google

Hey - Look what I get from google -- This forum; with your comment which is absolutely NO HELP AT ALL! What a waste of internet space.. next...

I agree with others that you should avoid interupts.

simondid:
hey

so i goth this keypad lcd shield with have 5 buttons witch i wut like to make an intterrupt function for becouse my main loop is kinda long and keeps a lot off othere stuff and varibals updated but alle the 5 buttons from the shield lands on analog pin 0 witch aint a intterrupts enabled pin is there any work arounds ??

link to the keypad shield
Arduino_LCD_KeyPad_Shield__SKU__DFR0009_-DFRobot

In case you want to combine blocking and slow code in your loop function ewith fast buton readings, use a timer interrupt! Set a timer interrupt frequency of about 500Hz, then evaluate the button state changes 500 times per second within your timer interrupt handling function!

I think you could get away with 50 times/per second Interupt Timer. If you look at the code for the LCD shield you may see how they are handling
it. Look at the Linksprite LCD code.

http://linksprite.com/wiki/index.php5?title=16_X_2_LCD_Keypad_Shield_for_Arduino

If you're using the Arduino UNO with the 16x2 LCD Keypad Shield; you can use Pin Change Interrupts on pin A0.

However; Only Left, Up, Right, Down pull the line low enough to trigger the interrupt ( misses Select ).

To overcome this; I soldered a 4.3K-ohm resistor from A0 to GND on top of the shield and used the below values. Now every button causes a Pin Change Interrupt.

enum Buttons { UP, DOWN, RIGHT, LEFT, SELECT, NONE };  // Button Options
Buttons Current_Button = NONE;

void ButtonCheck(int adc_value) {

    // The ISR will trigger when button is pressed and when it is let-go
    // Keypad WITH 4.3K-ohm Resistor A0 to GND
    if (adc_value >= 523) { Current_Button = NONE; return; }
    if (adc_value < 46) { Current_Button = RIGHT; }
    else if (adc_value < 155) { Current_Button = UP; }
    else if (adc_value < 269) { Current_Button = DOWN; }
    else if (adc_value < 381) { Current_Button = LEFT; }
    else if (adc_value < 523) { Current_Button = SELECT; }

}

void setup() {
   cli();   // disable interrupt

   // Setup Pin Change Interrupt for Buttons
   PCICR =0x02;                  // Enable 'PCIE1' bit of PCICR Pin Change Interrupt the PCINT1 interrupt
   PCMSK1 = 0b00000001;          // Pin Change Interrupt Mask ( NA, RESET, A5, A4, A3, A2, A1, A0 ) - Activate A0 
   sei(); //allows interrupts
}

ISR(PCINT1_vect) {
   ButtonCheck(analogRead(0));
}
void ButtonCheck(volatile int adc_value) {

It does not make sense to use the volatile keyword in a function argument's type.

Thanks for that; I've changed it. Also went with 4.3K as I noticed on various board 4.3K wasn't quite enough to trigger the interrupter.