Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile int NbTopsFan1;
- volatile int NbTopsFan2;
- #include <LiquidCrystal.h>
- int Calc1;
- int Calc2;
- int hallsensor1 = 2; //Arduino Pin von Sensor 1
- int hallsensor2 = 3; //Arduino Pin von Sensor 2
- LiquidCrystal lcd(9, 8, 6, 5, 4, 10);
- void rpmSensor1 () //Interrupt funktion für Sensor 1
- {
- NbTopsFan1++; //Impulszählvariable Sensor 1 +1
- }
- void rpmSensor2 () //Interrupt funktion für Sensor 2
- {
- NbTopsFan2++; //Impulszählvariable Sensor 2 +1
- }
- void setup()
- {
- Serial.begin(9600);
- pinMode(hallsensor1, INPUT); //Initialisiert Pin als Input
- pinMode(hallsensor2, INPUT); //Initialisiert Pin als Input
- attachInterrupt(digitalPinToInterrupt(hallsensor1), rpmSensor1, RISING);
- attachInterrupt(digitalPinToInterrupt(hallsensor2), rpmSensor2, RISING);
- lcd.begin(16, 2);
- //delay(500);
- }
- void loop ()
- {
- NbTopsFan1 = 0;
- NbTopsFan2 = 0;
- sei(); //interrupts aktivieren (also darauf hören und funktion ausführen und nicht ignorieren)
- delay (1000); //Wait 1 second
- cli(); //interrupts deaktivieren (also nicht darauf hören und somit ignorieren)
- Calc1 = (NbTopsFan1 * 60 / 300); //(Pulse frequency x 60) / 5Q, = flow rate in L/min
- Calc2 = (NbTopsFan2 * 60 / 300);
- lcd.setCursor(1, 0);
- lcd.print("In: ");
- lcd.print (Calc1, DEC); //Ausgabe des errechneten Durchflusses von Sensor 1
- lcd.print (" L/min.");
- lcd.setCursor(1, 1);
- lcd.print("Out:");
- lcd.print (Calc2, DEC); //Ausgabe des errechneten Durchflusses von Sensor 2
- lcd.print (" L/min.");
- Serial.print (Calc2, DEC); //Prints the number calculated above
- Serial.print (" L/min. OUT\r\n"); //Prints "L/hour" and returns a new line
- Serial.print (Calc1, DEC); //Prints the number calculated above
- Serial.print (" L/min. IN \r\n"); //Prints "L/hour" and returns a new line
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement