Liquid milk diesel gasoline Fuel Flow Sensor Test (OF05ZAT )

Описание к видео Liquid milk diesel gasoline Fuel Flow Sensor Test (OF05ZAT )

1.Flow Sensor Here :
https://www.aliexpress.com/item/32846...

2.Arduino Mega Mini Here:
https://www.aliexpress.com/item/32850...

3.Visual Studio with Arduino

4. Source Code
The source code is released.
Take it and click the Like button

Code Below.....




// Name: FuelFlowSensor.ino
// Created: 2020-03-30
// Author: Boris Lim ROK
// [email protected]
//
// Arduino Interrupt Pin 0, 1, 2, 3, 4, 5
// --------------------------------------------------------------------------------------------
// UNO : 2, 3
// Mega2560 : 2, 3, 21, 20, 19, 18
// Leonardo, Micro, 32u4 : 3, 2, 0, 1, 7,
//

#define _PIN_FLOW_PULSE_IN 2
#define _PIN_RESET_BTN 3

volatile uint32_t unpulseCount = 0; // volatile : RAM Write (Interrupt Fast Variable)
uint32_t undisplayCount = 0;

bool bdetectOn = false;
bool bReset = false;

#define _DISPLAY_TIME_SEC 1000

uint32_t unlastDisplay = 0;

void setup() {
//Assign Interrupt of Hall Pulse Port
pinMode(_PIN_FLOW_PULSE_IN, INPUT);
attachInterrupt(digitalPinToInterrupt(_PIN_FLOW_PULSE_IN), detectInterruptSignal, FALLING); // RISING(LOW->HIGH), FALLING(HIGH->LOW),CHANGE

//Assign Interrupt of Reset Button Port
pinMode(_PIN_RESET_BTN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(_PIN_RESET_BTN), detectinterruptReset, RISING); // RISING(LOW->HIGH), FALLING(HIGH->LOW),CHANGE

Serial.begin(57600); //115200,57600,9600

}




void loop() {
if (millis() - unlastDisplay >= _DISPLAY_TIME_SEC) {

unlastDisplay += _DISPLAY_TIME_SEC;

undisplayCount = unpulseCount;

if (bdetectOn & !bReset) { // flow display
displayPulse();
} //if
else if (bReset) { // Reset
displayReset();
}
}//if


}


void displayPulse()
{
Serial.print("PULSE:");
Serial.print(undisplayCount);
Serial.print(", ");
Serial.print("Liter:");

float fliter;

//fliter = undisplayCount * 4.6E-4; // = * 0.00046

fliter = undisplayCount * 6.41E-3; // = * 0.00641

Serial.println(fliter,3);
}

void displayReset()
{
Serial.println("Reset.....initialize...OK:");
bReset = false;
}

void detectInterruptSignal()
{
unpulseCount++;
bdetectOn = true;
}

void detectinterruptReset()
{
unpulseCount = 0;
undisplayCount = 0;
bdetectOn = false;
bReset = true;
}

Комментарии

Информация по комментариям в разработке