problems with attachInterrupt

GeneApperson
Posts: 239
Joined: Wed Jun 01, 2011 9:53 pm
Location: Pullman WA
Contact:

Re: problems with attachInterrupt

Post by GeneApperson » Thu Sep 01, 2011 8:52 pm

No problem. I'm glad it's working. Let me know if you have any other questions or issues.

Gene Apperson
Digilent

mhe.abdul@gmail.com
Posts: 1
Joined: Tue Mar 22, 2016 10:09 am

Re: problems with attachInterrupt

Post by mhe.abdul@gmail.com » Fri Mar 25, 2016 10:58 am

Dear all,

I am also facing problem in attachInterrupt () function I am using this to read Incremental Rotary Encoder, my program is working properly on Arduino board but when I use same program its not working properly.

If I turn my encoder to clock wise its showing counter increasing, but when I turn in anti clock wise its also showing same increasing count in place of decreasing count, plz do help

hare is my code.
/*-------------------------------------------------------------*/
unsigned long pulse = 500000;

void setup() {
Serial.begin (9600);
attachInterrupt(0, ai0, RISING);
attachInterrupt(1, ai1, RISING);
delay(1500);
Serial.println(5000000);
}
void loop() {
Serial.println(pulse);
delay(150);

}
void ai0() {

if (digitalRead(3) == LOW) {
pulse++;
}
else {
pulse--;
}
}
void ai1() {

if (digitalRead(2) == LOW) {
pulse++;
}
else {
pulse--;
}
}
/*---------------------------------------------------*/

User avatar
majenko
Site Admin
Posts: 2188
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: problems with attachInterrupt

Post by majenko » Fri Mar 25, 2016 11:43 am

Which board are you using it with?
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

Post Reply