Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile int FlowPulse; //measuring the rising edges of the signal
- volatile int FlowPulse1; //measuring the rising edges of the signal
- int Calc;
- int Calc1;
- int Calc2;
- int flowsensor = 2; //The pin location of the sensor
- int flowsensor1 = 3; //The pin location of the sensor
- void setup() {
- pinMode(flowsensor, INPUT); //initializes digital pin 2 as an input
- Serial.begin(9600); //This is the setup function where the serial port is initialised,
- attachInterrupt(0, rpm, RISING); //and the interrupt is attached
- pinMode(flowsensor1, INPUT); //initializes digital pin 2 as an input
- Serial.begin(9600); //This is the setup function where the serial port is initialised,
- attachInterrupt(1, rpm1, RISING); //and the interrupt is attached
- }
- void loop() {
- FlowPulse = 0; //Set NbTops to 0 ready for calculations
- sei(); //Enables interrupts
- delay(1000); //Wait 1 second
- cli(); //Disable interrupts
- Calc = (FlowPulse * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour
- Serial.print (Calc, DEC); //Prints the number calculated above
- Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
- FlowPulse1 = 0; //Set NbTops to 0 ready for calculations
- sei(); //Enables interrupts
- delay(1000); //Wait 1 second
- cli(); //Disable interrupts
- Calc1 = (FlowPulse1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour
- Serial.print (Calc1, DEC); //Prints the number calculated above
- Serial.print (" L/hour1\r\n"); //Prints "L/hour" and returns a new line
- sei(); //Enables interrupts
- delay(2000); //Wait 1 second
- cli(); //Disable interrupts
- Calc2 = (Calc - Calc1);
- Serial.print (Calc2, DEC); //Prints the number calculated above
- Serial.print (" L/hour rozdil\r\n"); //Prints "L/hour" and returns a new line
- Serial.print (" \r\n");
- sei(); //Enables interrupts
- delay(1000); //Wait 1 second
- cli(); //Disable interrupts
- }
- void rpm () //This is the function that the interupt calls
- {
- FlowPulse++; //This function measures the rising and falling edge of the hall effect sensors signal
- }
- void rpm1 () //This is the function that the interupt calls
- {
- FlowPulse1++; //This function measures the rising and falling edge of the hall effect sensors signal
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement