I'm not used to coding alot so wanted to know a code for Non - contact liquid level sensor. I have this code in which the sensor senses the liquid and if liquid is present it shows HIGH and if liquid is not present is shows LOW. I want output like if liquid is present then keep the motor on and if liquid is not present make motor off. Also i want to send this data through mavlink.
This is code:
int Liquid_level=0;
void setup() {
Serial.begin(9600);
pinMode(5,INPUT);
}
void loop() {
Liquid_level=digitalRead(5);
Serial.print("Liquid_level= ");
Serial.println(Liquid_level,DEC);
delay(1000);
}
Thanks in advance.