[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: http://forum.arduino.cc/index.php?topic=45239.40;wap2.
Cheers,
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 2/18/15, 10:58 PM |
Seen: 4162 times |
Last updated: 2/22/15, 12:55 PM |
I could not get this sample to work on the INDIO, are the interrupts different?