External interrupt related problem

I have used Arduino Uno for external interrupt on INTO pin. The interrupt works on changing logic. So while INTO pin gets pulsed it does high the pin 13. But while logic goes to low level I defined PIN 13 as low. For this purpose I used timer1. When pulse stops, I scan INTO pin for 15 sec, if its logic level is low, I simply did the pin 13 low, again while gets pulse, pin13 will be high. But the prob is when logic level goes to low, Pin 13 is still high and I don’t understand. I have upload my code. Thanks for any kind of suggestion.

interrupt.ino (769 Bytes)

Hello and welcome,

There is your problem, most likely:

int pin = 13;
...
if(scan==30 && pin == LOW)

Giving meaningful names to your variables will avoid this kind of problems… :wink:

Edit: I’ve read your code too fast… Did you mean:

if(scan==30 && digitalRead(pin) == LOW)

Also the previous if statement have the same problem.

And you can’t read an ouput, so I’m confused about what you are trying to do…

guix:
Hello and welcome,

There is your problem, most likely:

int pin = 13;

...
if(scan==30 && pin == LOW)




~~Giving meaningful names to your variables will avoid this kind of problems... ;)~~

Edit: I've read your code too fast... Did you mean:


if(scan==30 && digitalRead(pin) == LOW)




Also the previous if statement have the same problem.

And you can't read an ouput, so I'm confused about what you are trying to do...

Thank u very much. I'm very sorry for such kind of mistake. It's working now.

guix:
And you can’t read an ouput, so I’m confused about what you are trying to do…

You most certainly CAN read an output, and it will return the current state of the output pin.

Regards,
Ray L.