Hello Everyone, thanks for your help firstly, I have a question, I want to get each flow meter output independently on DO Pin2 and DO Pin 3, I wrote a code which I posted below, but when I run the program when I give the start's and stop's input, only my start is running or when I give the start's and stop's input again only my stop is running, I want to get output of start and stop independently, I guess there is a problem on my interrupt codes but I couldn't get the right answer, could you please help me ?
This is my code which just runs the start;
volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc;
int Start;
int Stop;
void ulu () //This is the function that the interupt calls
{
Rising_Falling_Edge1++; //This function measures the rising and falling edge of the hall effect sensors signal
Rising_Falling_Edge2++; //This function measures the rising and falling edge of the hall effect sensors signal
}
void setup() //The setup() method runs once, when the sketch starts
{
pinMode(2, INPUT); //initializes digital pin 2 as an input
pinMode(3, INPUT); //initializes digital pin 3 as an input
Serial.begin(9600); //This is the setup function where the serial port is
}
void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
cli();
attachInterrupt(0, ulu, RISING); //and the interrupt is attached
delay(1000);
sei();
Rising_Falling_Edge1 = 0; //Set Rising_Falling_Edge to 0 ready for calculations
delay (1000); //Wait 1 second
Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour
Serial.print ("Start:");
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
attachInterrupt(1, ulu, RISING); //and the interrupt is attached
delay(1000);
Rising_Falling_Edge2 = 0; //Set Rising_Falling_Edge to 0 ready for calculations
Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour
Serial.print ("Stop:");
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
}
[code]
and this is my code just runs my stop;
[code]volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc;
int Start;
int Stop;
void ulu () //This is the function that the interupt calls
{
Rising_Falling_Edge1++; //This function measures the rising and falling edge of the hall effect sensors signal
Rising_Falling_Edge2++; //This function measures the rising and falling edge of the hall effect sensors signal
}
void setup() //The setup() method runs once, when the sketch starts
{
pinMode(2, INPUT); //initializes digital pin 2 as an input
pinMode(3, INPUT); //initializes digital pin 3 as an input
Serial.begin(9600); //This is the setup function where the serial port is
}
void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
cli();
attachInterrupt(0, ulu, RISING); //and the interrupt is attached
Rising_Falling_Edge1 = 0; //Set Rising_Falling_Edge to 0 ready for calculations
delay (1000); //Wait 1 second
Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour
sei();
Serial.print ("Start:");
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
attachInterrupt(1, ulu, RISING); //and the interrupt is attached
Rising_Falling_Edge2 = 0; //Set Rising_Falling_Edge to 0 ready for calculations
delay(1000);
Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour
Serial.print ("Stop:");
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
}
[code]