External interrupt on pin 3 does't work as it should

I'm using this code to count the number of rotations of my robot's 2 driving wheels. Each wheel axe has an optical sensor attached which gives an impulse at each passing stroke.

void setup() { Serial.begin(9600); pinMode(2, INPUT); attachInterrupt(0,update_SF_wheel,FALLING); pinMode(3, INPUT); attachInterrupt(1,update_DF_wheel,FALLING); } volatile unsigned int rotations_SF_wheel = 0; volatile unsigned int rotations_DF_wheel = 0; void update_SF_wheel() { rotations_SF_wheel++; } void update_DF_wheel() { rotations_DF_wheel++; } void loop() { delay(250); Serial.print("SF1: "); Serial.print(rotations_SF_wheel); Serial.print(" DF 2: "); Serial.println(rotations_DF_wheel); }

The code returns correct values for the sensor which uses the interruppt 0 on pin 2 but nerver increments the value related to the other sensor...

Both sensors work ok (if i swhich them between pin 2 and 3 the same results appears)...

If i try using only pin 3 interrupt - the counter still does not increase.....(i was thinking of conflicts between the 2 interrupts)...

However the pin 3 interrupt increases the counter if i repeat inserting and extracting a VCC conected wire into pin 3.....

What's wrong...?

Sounds like your sensor needs a pull-up resistor. Try adding digitalWrite(3, HIGH) at the end of setup(). If that helps, do the same for Pin 2.