attachInterrupt getting stuck

Hi guys, I am trying to run this code:

include <LCD16x2.h>

include <Wire.h>

LCD16x2 lcd;
void setup() { // put your setup code here, to run once:
lcd.lcdGoToXY(1,1); lcd.lcdWrite("SPEED:");
lcd.lcdGoToXY(1,2); lcd.lcdWrite("DIRECTION:");
//Setup Pins
pinMode(0, INPUT_PULLUP);
void WindSpeed(){
void loop() {

I am using A0 to power a hall sensor and digital pin 2 as an input for the hall sensor. The issue is that the “0” is never written to the LCD nor a “1” when there is a magnet by the hall sensor. But when I change the attachInterrupt’s pin to 1 (INT1), then a “0” is written (The “1” is never written). This only works if there is nothing on Interrupt pin, as soon as I switch the hall sensor input wire to digital pin 3 and restart the arduino, the “0” is no longer there.

Don’t try to do interrupt driven things (like using I2C comms) in an interrupt functon where interrupts are turned off. It will hang your code.

Let the ISR just set a flag and let the loop function test that flag and handle printing to the screen.

okay, I understand now that the microcontroller will be hung up once it gets into the ISR WindSpeed() because it uses I2C comm which itself tries to use interrupts however interrupts are already disabled.

But does this explain why a "0" was never written?

Because it got set to write the 0, but before it could finish the interrupt fired and locked it down.

This may not be your problem but this is on a serial pin and from the code you posted. I don't see why you would want it.

pinMode(0, INPUT_PULLUP);

I think you intended to put a pull up the interrupt 0 pin.

pinMode(2, INPUT_PULLUP);

thank you cattledog, I missed that