[Solved] Interruption on panel buttons
Dear,
I would like to use interruption in order to switch the working mode of Industruino when pressing a button.
From computing mode to setup mode for example.
What is the port connection to attach the interrupt ?
I am still using the UC1701 lib, hope that is not a problem.
Best regards,
The 1286 Topboard has its button inputs connected to pin change interrupts PCINT 4, 5 & 6 for buttons Down, Enter and Up respectively. Please use this code as an example:
#include <UC1701.h>
static UC1701 lcd;
volatile int modeFlag = 0;
void setup() {
lcd.begin(); //enable LCD
// Enable Pin Change Interrupt 6.
PCMSK0 = (1 << PCINT6);
PCICR = (1 << PCIE0);
// Global Interrupt Enable
sei();
}
ISR (PCINT0_vect)
{
modeFlag = 1;
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("waiting ");
if (modeFlag == 1) {
lcd.setCursor(0, 0);
lcd.print("triggered");
delay(1000);
modeFlag = 0;
}
}
This demo sketch will show "waiting" on the Industruino's LCD screen, when you press the "Up" button an interrupt will be triggered and "triggered" will show on the LCD for one second. Please test against the "modeFlag" integer to jump between your "computing" and "setup" routines. To attach the interrupt to the "Enter" or "Down" button change "PCINT6" in line "PCMSK0 = (1 << PCINT6);" to PCINT5 or PCINT4.
Cheers,
Loic
Good Day,
This works perfectly to raise an event when "up" button is pressed.
Thanks to your code, I found a bit more details there:;wap2. could not get this sample to work on the INDIO, are the interrupts different?