// https://forum.arduino.cc/t/extension-of-the-program-with-additional-2-parameters-does-not-work/1049873/8
int pressureMeasurement;
void setup ()
{
Serial.begin (9600); // speed of the COM port to read
pinMode (7, OUTPUT); // pin indication for relay 1 at cylinder 1
pinMode (8, OUTPUT); // pin indication for relay 2 at cylinder 2
digitalWrite (7, LOW); // turn off 1 relay at cylinder 1
digitalWrite (8, LOW); // turn off relay 2 at cylinder 2
}
void loop () {
static unsigned int loopCounter;
delay (333); // slow this down crudely
pressureMeasurement = analogRead (A0); // indication of the pin reading the data from the pressure sensor
Serial.println();
Serial.print(loopCounter); loopCounter++;
Serial.print(" pressure = "); // string for the port monitor
Serial.println(pressureMeasurement);
if (pressureMeasurement> 128) {// what measurement should the reaction take place at? 1024 is 5volt 240 = 1.17v 230 = 1.12v 225 = 1.1v 184 = 0.9v 143 = 0.7v
Serial.println ("block 1");
digitalWrite (7, HIGH); // turn on the relay at cylinder 1
digitalWrite (8, HIGH); // turn on the relay at cylinder 2
delay (200); // the relay is turned on for 0.2 seconds
digitalWrite (8, LOW); // turn off the relay for 2 cylinders
delay (2000); // time when the relay for 2 cylinders is turned off
if (pressureMeasurement > 256) {// what measurement should the reaction take place at?
Serial.println ("block 2");
digitalWrite (7, HIGH); // turn on the relay at cylinder 1
digitalWrite (8, HIGH); // turn on the relay at cylinder 2
delay (400); // the relay is turned on for 0.4 seconds
digitalWrite (8, LOW); // turn off the relay for 2 cylinders
delay (2000); // time when the relay for 2 cylinders is turned off
if (pressureMeasurement > 768) {// at what measurement is to be reacted?
Serial.println ("block 3");
digitalWrite (7, HIGH); // turn on the relay at cylinder 1
digitalWrite (8, HIGH); // turn on the relay at cylinder 2
}
}
else {
Serial.println ("block X, analog below 128.");
digitalWrite (7, LOW); // turn off the relay at cylinder 1
delay (100); // delay for switching off the relay no.2
digitalWrite (8, LOW); // turn off the relay at cylinder 2
}
delay (100); // every how many seconds should the sensor read?
}
}