ArduinoGeneral

Romeo V2, Button S1-S5 and interrupt

userHead AlexeyVorotnikov 2016-12-30 08:48:47 1582 Views3 Replies
In the example for the use of buttons S1-S5 is used to read the signal on port A0 in the loop(). How to use an interrupt when the signal changes on port A0 (when the button S1-S5 is pressed)?
2017-01-03 20:21:51 Hi Sir,

The if function is relatively simple, so may I know why do you want a Interrupt like PCINT1_vect on UNO (ATmega328p)? Whats your using environment?
userHeadPic Wendy.Hu
2016-12-30 22:38:39 Hi, Wendy! Thanks!
But to catch pressing one of the buttons S1-S5 on the board of Romeo v2 (DFR0225) your code: "if(analogRead(A0)>0) {digitalWrite(interrupt,HIGH);}" should be in the loop() - it doesn`t suit me.
I do not want to use a loop() to read values on the port A0.
I need to use an interrupt on an analog port A0 of Romeo (Atmega32u4), like interrupt PCINT1_vect on UNO (ATmega328p)
userHeadPic AlexeyVorotnikov
2016-12-30 21:43:22 Hi

I guess if we can try the following code to the example code for your interrupt?

if(analogRead(A0)>0)
{
digitalWrite(interrupt,HIGH);
}

Let me know if you have any problem. :)
userHeadPic Wendy.Hu