Pages: [1]   Go Down
Author Topic: [Arduino uno R3] INT0 triggered by digital pin 3  (Read 625 times)
0 Members and 1 Guest are viewing this topic.
Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've made simple circuit to master Arduino interrupts. I wrote also a simple program keeping track of how many times button has been pressed. For unknown reasons Arduino seems to call INT0 interrupt even on change on digital pin 3. What am I doing wrong?

Here's code, and circuit:
Code:
volatile int count0 = 0;

void setup()
{
  Serial.begin(9600);
 
  // Set input and pullups
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);
  pinMode(3, INPUT);
  digitalWrite(3, HIGH);
 
  // Set INT0 interrupt:
  attachInterrupt(0, interrupt0, FALLING);
}

void loop()
{
  Serial.println(count0);
  Serial.println(count1);
  delay(1000);
}

void interrupt0()
{
  Serial.println("Interrupt0");
  count0++;
}



Uploaded with ImageShack.us
Logged

‘The most exciting phrase to hear in science, the only one that heralds new discoveries, is not "Eureka!", but rather, "Hmm... that’s funny.

Offline Offline
Full Member
***
Karma: 0
Posts: 197
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This doesn't help you but just btw this
Code:
pinMode(2, INPUT);
  digitalWrite(2, HIGH);

can be changed to this

Code:
pinMode(2,INPUT_PULLUP);
Logged

Pages: [1]   Go Up
Jump to: