Problem with using two interrupts (MEGA 2560)

Hi. i have some problem when using two interrupts on mega 2560 board. i use two hall effect sensor, one for water flow and other for rpm on a turbine. there are no output display on the serial monitor. i never use interrupts before and this is the first time.

here the code that i try to write. can anyone show me the correct way to write the code??

volatile int hallone;
int Calc;
int hallsensor = 2; 

volatile byte halltwo;
unsigned int rpm_hall;
unsigned long timeold;

void waterflow ()     
{ 
  hallone++;  
} 

 void turbinerpm()
 {
   halltwo++;
 }
 
void setup() 
{ 
  pinMode(hallsensor, INPUT);
  Serial.begin (9600); 
  attachInterrupt(0, waterflow, RISING); 
  attachInterrupt(1, turbinerpm, RISING);
  halltwo = 0;
  rpm_hall = 0;
  timeold = 0;  
}

void loop() 
{  
   interrupts ();
   hallone = 0;  
   Calc = (hallone * 60 / 7.5);
   Serial.print (Calc, DEC); 
   Serial.println (" L/hour\r\n");
   delay (1000);
  noInterrupts ();
  
  interrupts ();
  if (halltwo >= 20) 
  { 
  rpm_hall = 30*1000/(millis() - timeold)*halltwo;
  halltwo = 0;
  Serial.println(rpm_hall,DEC);
  noInterrupts ();
}
}

thank you…

Check your wiring. Which Arduino pins are the Hall sensors connected to and do you have resistors on them to pull their voltage high or low ?

Incidentally, the result of this calculation  Calc = (hallone * 60 / 7.5);will be an integer despite the division by 7.5 because Calc is defined as an int.

the pins for both sensor are correct. i use 10K on both sensors to pull high.

Do the interrupt pins get pulled low by the Hall sensors when they are activated ? In other words are the Hall sensors wired from the interrupt pins to ground ?

Why are you disabling and then immediately re-enabling interrupts:

  noInterrupts ();
  
  interrupts ();

?

Why are you disabling interrupts at the end of loop(), and then immediately re-enabling them:

void loop() 
{  
   interrupts ();
<snip>
  noInterrupts ();
}

Add an LED with resistor, and toggle it in the ISR, to confirm that interrupts are happening (after you stop diddling with them).

Sorry for the late reply. Thanks for both reply. well, i just been school on interrupt on the other forum. it is my mistake to put interrupt() and nointerrupt(). i just have to put interrupt() on setup and it work. thanks for the reply.

i just have to put interrupt() on setup and it work.

Since the default state is interrupts enabled, you don't even need to do that.

   hallone = 0;  
   Calc = (hallone * 60 / 7.5);

I'm going to go out on a limb here and predict that Calc is pretty much always ending up 0. Is this what you intended?