arduino / arduino/Arduino

External interrupts misfiring

Open
#9,704 5 comments 0 reactions 0 assignees View on GitHub
Component: Core Type: Bug
Dominant language
Java
Stars
14.6k
Forks
7k
PR merge metrics
No merged PRs in 30d

Description

Looks like attachInterrupt(digitalPinToInterrupt(2), juhu, FALLING); always akt like CHANGE.

No matter what i choose - RISING, FALLING, HIGH or CHANGE it always behave like CHANGE.

Here is the simple sketch:
```c++
void setup()
{
pinMode(2, INPUT);
pinMode(3, OUTPUT);

attachInterrupt(digitalPinToInterrupt(2), juhu, RISING);
}

void loop()
{
}

void juhu() {
digitalWrite(3, HIGH);
delayMicroseconds(200);
digitalWrite(3, LOW);
}
```
Then top two lines on the scope picture, is a nice clean square wave, made by an optocoupler.
The buttom two lines is the resulting signal on output pin 3.

No matter, if i stand on my head and sing a terrible song, or choose RISING, FALLING or CHANGE, the result is the same - always two signals with one square wave.

Can You tell me what is wrong?

I think the arduino ide translates all modes to CHANGE

![image-20200131_140816](https://user-images.githubusercontent.com/60551859/73596950-a7d4be80-4527-11ea-8de2-d1cff8f14367.jpg)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied sketch's attachInterrupt(digitalPinToInterrupt(2), juhu, ...) behavior and compare RISING, FALLING, HIGH, and CHANGE while observing the input and output on a scope. Determine whether the interrupt mode is being handled incorrectly or whether the wiring and optocoupler produce both edges; done means the cause is identified and the selected modes behave distinctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.