Hi there,
I am attempting to create an automatic project that rely of 4 dc pumps, all of them are controlled using time. for now, i can only do it with delay syntax (blocking code), and don't know how to implement non-blocking method for this code. anyone can guide me how to make it non-blocking?
here is the test code (of course the whole project code is not finished, just test code at this moment):
#define pompa_a 7
#define pompa_b 8
#define pompa_c 9
#define pompa_d 10
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pompa_a, OUTPUT);
pinMode(pompa_b, OUTPUT);
pinMode(pompa_c, OUTPUT);
pinMode(pompa_d, OUTPUT);
pompaNuang (pompa_b, 80);
}
void loop() {
// put your main code here, to run repeatedly:
}
void pompaNuang (int pump, int ml){
int pompa;
double y;
switch (pump) {
case pompa_a:
pompa = pompa_a;
y = -0.0568 * (ml^2) + 66.154 * ml;
break;
case pompa_b:
pompa = pompa_b;
y = -0.0268 * (ml^2) + 53.651 * ml;
break;
case pompa_c:
pompa = pompa_c;
y = -0.0223 * (ml^2) + 49.775 * ml;
break;
case pompa_d:
pompa = pompa_d;
y = -0.0505 * (ml^2) + 64.876 *ml;
break;
default:
Serial.println("wrong pin");
}
Serial.print("start pump:");
Serial.print(pompa);
Serial.print(", duration:");
Serial.println (int(y));
digitalWrite(pompa, HIGH);
delay(int(y));
digitalWrite(pompa,LOW);
}
Thank you very much.