Interrupt RISING

Moderator: Adrian

segrest
Posts: 5
Joined: Fri Aug 22, 2014 5:28 am

Interrupt RISING

Postby segrest » Tue Feb 14, 2017 5:50 am

Hello Everyone,

I have an interrupt service routine (ISR) that doesn't seem to be working as expected under simulation.

In setup I have the following two lines:

pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), beepInt, RISING);

When I click on the interrupt pin (pin 2 in my case) in the Arduino display the interrupt is being created and the ISR is executed. The problem is that the ISR seems to be firing as long as interruptPin is HIGH rather than only once each time it rises from low to high.

Can you verify that the RISING parameter in the attachInterrupt routine is behaving correctly in the simulator? Is there some operational detail in using the simulator that I might be overlooking?

Bob

Simulator_admin
Site Admin
Posts: 237
Joined: Thu Feb 02, 2012 6:07 pm

Re: Interrupt RISING

Postby Simulator_admin » Tue Feb 14, 2017 7:56 am

We just tried the sketch below and it seems to work OK. After the attachInterrupt line, the green input pin can be clicked and it can be seen that only when the pin becomes green again does the ISR fire which is beepInt. Thanks

Code: Select all

// Simulate(Uno) link sketch to Arduino board here

#define interruptPin 2
int i=0;

void beepInt(void)
{
    i++;
}

void setup() {
  // put your setup code here, to run once:
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), beepInt, RISING);
}

void loop() {
  // put your main code here, to run repeatedly:

}


Aarontulge
Posts: 7
Joined: Tue Sep 05, 2017 6:54 am

Interrupt RISING

Postby Aarontulge » Sun Sep 10, 2017 1:55 pm

Hello everybody

Im a complete newbie in electronics, however Martins videos were so interesting, that I've started tinkering a bit.

Im working on my first 'serious' project: turning assistant lights. Idea is straightforward - when the headlights are on and an indicator is on - appropriate foglight goes on for 5 seconds.

So far sketch looks like that:

int fogA = 8;
int fogB = 7;
int IndLeft = 4;
int IndRight = 2;


void setup

pinModefogA, OUTPUT;
pinModefogB, OUTPUT;
pinModeIndLeft, INPUT;
pinModeIndRight, INPUT;


void loop

if digitalReadIndLeft == HIGH

digitalWritefogA, HIGH;
delay5000;


else

digitalWritefogA,LOW;


if digitalReadIndRight == HIGH

digitalWritefogB, HIGH;
delay5000;

else

digitalWritefogB,LOW;




but there is a problem: if I swap indicators quickly - the former one stays on for 5 seconds.
I want arduino to interrupt digitalWritefogB, HIGH; delay5000; procedure.

Any ideas?


Return to “Simulator 1.05”

Who is online

Users browsing this forum: No registered users and 1 guest