[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,

Desvaux Hugues
Desvaux Hugues
55
| 5 1 2
Asked on 2/18/15, 10:58 PM
1
vote
4161 Views

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

 

Loic De Buck
Loic De Buck
1263
| 3 1 3
Answered on 2/20/15, 8:38 AM
2
vote

I could not get this sample to work on the INDIO, are the interrupts different?

Justin Smith
on 5/11/15, 5:50 PM

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,

 

Desvaux Hugues
Desvaux Hugues
55
| 5 1 2
Answered on 2/22/15, 12:33 PM
0
vote

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!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

5 follower(s)

Stats

Asked: 2/18/15, 10:58 PM
Seen: 4161 times
Last updated: 2/22/15, 12:55 PM