Два датчика расхода воды с использованием датчиков Холла
- Войдите на сайт для отправки комментариев
Чт, 26/05/2016 - 16:50
День добрый! Помогите, пожалуйста, чайнику.
Может кто подскажет, как к одной ардуинке два датчика потока на основе датчика холла подключить с выводом на дисплей?
Код для одного датчика простейший и работает:
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27,16,2); // Задаем адрес и размерность дисплея (16 символов 2 ряда)
volatile int NbTopsFan=0; //measuring the rising edges of the signal
double Calc;
int hallsensor = 4; //The pin location of the sensor малый сенсор
void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensors signal
}
// The setup() method runs once, when the sketch starts
void setup() //
{
pinMode(hallsensor, INPUT);//initializes digital pin 2 as an input
//Calc = digitalRead(4);
Serial.begin(9600); //This is the setup function where the serial port is initialised,
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
lcd.init(); // Инициализация lcd
lcd.backlight(); // Включаем подсветку
lcd.clear();
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop ()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000);
Calc = (NbTopsFan*60/7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour
lcd.setCursor(0, 0); //устанавливаем курсор в начало второй строки
lcd.print("Qi=");
lcd.print (Calc);// Выводим текст
lcd.print("l/s");
}