Remote tractor Shutdown Ver 2.0

Hi guys,

I'm back again and I see that 120 days has passed and my post has been closed. Which is fine, as I have learned a lot since then but am still very ignorant.

The project has changed (simplified) since then, so what I ended up going with for the wireless communication is a 355MHz long range (5km) transmitter/receiver package and looks a little something like this:

The remote end has a 12V solar panel that charges a 12V lithium battery which powers the transmitter of the 355MHz RF Tx, and is received on the Rx side, outfitted with a LM7805 (5V Voltage regulated power supply, fed by the 12V tractor battery) which powers a Mega 2560 board. The 5V supply is also used to supply the 2 SSR's with a reference voltage in order to trigger either high or low on the 2 Murphy switches (used as safety inputs for high temperature and low oil pressure on the tractor). They also trigger the remaining inputs, and are used to trigger the inputs of the 4 channel relay module as well. All of the mapping will be defined in what I have for code thus far, pasted below. Being that this is my first Arduino project (as well as first experience with python), I was hoping to get some input on my coding to make sure that I'm doing it right. I have been researching all that I can, but there are a number of details that aren't explained. Such as the best method for setting a variable to be the input read from a specific pin. Does one use "define", or "int"? What is the difference between "const int" and just "int"? I can't find any examples that are similar in structure enough to use with confidence. I have laid out all of the details of what the code should do within the code itself. I'll post up here what I have so far. The issue that I am fighting with right now is... well, you'll see where I stopped with my coding and explained it all in there. Thoughts?

/* Irrigation tractor shutdown system
 *  By: Craig Hatzel
 *  May 20, 2021
 *  The purpose for this code is to shut off a tractor that is being used to run an irrigation system via its PTO drive. At startup the Mega2560 will immediately send ouput pin A14 (Igntn) high - closing the NO 
 *  IGNITION relay, connected in parallel with the ignition switch; send output pin A15 (LEDStat) high for 1 min - activating the "Ready to Start" indicator LED; begin a 120,000 millisecond timer (2 min), at 
 *  the end of which it will initialize the monitoring (digitalread) of input pin A5 (MSOil) - delaying the emergency shutdown use of the oil pressure sensor for until there is actually oil pressure to monitor; 
 *  and it will also send ouput pin A13 high - reversing the linear actuator until the throttle triggers limit switch 1 (LS1, on input pin A1). The tractor then can be started  
 *  When the implement has completed its watering cycling the arm will trigger the pump motor to shut down. This is between 800-900 feet away from the tractor.
 *  at the same time a long range RF transmitter will be triggered, it's receiver mounted at the tractor. The receiver will use this signal to send a high signal to input A0 (RFTrig). That will call the 
 *  "Shutdown" loop to initiate and will include a time variable. If Shutdown is called from either pins A4 or A5, the included time variable will be 0; if it is called from pin A0, it will be 180,000 ms (3 min). 
 *  Shutdown: The output on pin A12 (DCFwd) will go high, activating the DC motor controller forward trigger until a high signal is received from tripping the limit switch LS1 on input pin A1. the program will 
 *  then use the delay command to pause all operations for the amount specified in the attached variable. Dependant upon the source of the trigger, it will either pause for 0 milliseconds, or 180,000 milliseconds
 *  after which time it will once again activate output pin 12 (DCFwd) and hold it high until a high signal is received on input pin A2 (LS2), caused by contacting the limit switch (LS2) located at the throttle's
 *  off position. And finally, the Mega will release the high level that was being held on output pin 14, Igntn, turning off the tractor's ignition.
 *  In case of a malfunction or system lockup, or if the tractor was not started by the time the indicator LED was tuned off, a low level reset can be initiated via pressing the reset button connected to input 
 *  pin A3 (Rst) which will close the loop between GND and RESET on the board until a low level reset sequence is initiated.
  */

#include "millisDelay.h" 
millisDelay ledDelay; // delay for led
millisDelay msoilDelay; // delay for msoil read
 const int RFTrig = 0; // RF input from pump on pin A0 
 const int LS1 = 1; // Limit switch at idle position on pin A1
 const int LS2 = 2; // Limit switch at off position on pin A2
 const int Rst = 3; // Reset sequence to ignore Murphy oil input for 2 min initiated on pin A3
 const int MSTmp = 4; // Murphy switch high temperature on pin A4
 const int MSOil = 5; // Murphy switch oil pressure (low) on pin A5
 const int DCFwd = 12; // Ouput to activate DC motor controller forward on pin A12
 const int DCBwd = 13; // Output to activate DC motor controller reverse on pin A13
 const int Igntn = 14; // Output to activate tractor power kill relay on pin A14
 const int LEDStat = 15; // Output to activate LED (1min) to indicate ignoring Murphy oil (2min) start procedure
 int rftrig = 0; // variable for A0 read value
 int ls1 = 0; // variable for A1 read value
 int ls2 = 0; // variable for A2 read value
 int rst = 0; // variable for A3 read value
 int mstmp = 0; // variable for A4 read value
 int msoil = 0; //variable for A5 read value

void setup() {
  // put your setup code here, to run once:
pinMode(RFTrig, INPUT); // set pin A0 as input
pinMode(LS1, INPUT); //set pin A1 as input
pinMode(LS2, INPUT); // set pin A2 as input
pinMode(Rst, INPUT); // set pin A3 as input
pinMode(MSTmp, INPUT); // set pin A4 as input
pinMode(MSOil, INPUT); // set pin A5 as input
pinMode(DCFwd, OUTPUT); // set pin A12 as output
pinMode(DCBwd, OUTPUT); // set pin A13 as output
pinMode(Igntn, OUTPUT); // set pin A14 as output
pinMode(LEDStat, OUTPUT); // set pin A15 as output
digitalWrite(Igntn, HIGH);  
digitalWrite(LEDStat, HIGH);
ledDelay.start(60000);  // start a 60sec delay for the "ok to start LED"
do {         
  digitalWrite(DCBwd, HIGH); // activate the dc motor in reverse to return idle arm to idle/start position
  } while (ls1 = LOW); // for as long as limit switch 1 is low/off and stop when limit switch 1 is hit
msoilDelay.start(120000); // start a 120sec delay

}
void loop() {
  // put your main code here, to run repeatedly:
 // check if the LED timer has timed out
  if (ledDelay.justFinished()) {
    digitalWrite(LEDStat, LOW); // turn led off
  } 
 // check if MSOil read delay has timed out
  if (msoilDelay.justFinished()) {
    msoil=digitalRead(MSOil); // Start reading data from the oil pressure input
  }
rftrig=digitalRead(RFTrig); // start monitoring the RFTrig input
ls1=digitalRead(LS1);  // Start monitoring Limit Switch 1
ls2=digitalRead(LS2); // Start monitoring Limit Switch 2
rst=digitalRead(Rst); // Start monitoring the reset switch
mstmp=digitalRead(MSTmp); // Start monitoring the tractor operating temperature


  }

void shutdown()  {
  // create function "shutdown"
do {
  digitalWrite(DCFwd, HIGH); // activate the DC motor forward (reducing RPM)
  } while (ls1 = LOW); // until limit switch 1 (idle) is triggered
delay(???) /*here is where i am stuck
* I want a variable named "source" to be carried into the function shutdown. "shutdown" would be called 1 of 3 ways. 1) a HIGH on RFTrig; 2) a HIGH on MSTmp; 3) a HIGH on MSOil, after the initial 2 min timer
* ran out. So here's the thing... if it was called by RFTrig, I want the delay to be 180000ms; but if it is called by either of the other 2 triggered inputs I want the delay to be 0. so obviously I need to create 
* int source in my setup, but i have no idea how to define/identify it, or how to have that variable carry over into "shutdown". HELP
 */

Hi,
Welcome back.

To add code please click this link;

Can you post a circuit diagram, a picture is worth a thousand words.

Thanks... Tom... :grinning: :+1: :coffee: :australia:

Sorry, new to this.

/* Irrigation tractor shutdown system
 *  By: Craig Hatzel
 *  May 20, 2021
 *  The purpose for this code is to shut off a tractor that is being used to run an irrigation system via its PTO drive. At startup the Mega2560 will immediately send ouput pin A14 (Igntn) high - closing the NO 
 *  IGNITION relay, connected in parallel with the ignition switch; send output pin A15 (LEDStat) high for 1 min - activating the "Ready to Start" indicator LED; begin a 120,000 millisecond timer (2 min), at 
 *  the end of which it will initialize the monitoring (digitalread) of input pin A5 (MSOil) - delaying the emergency shutdown use of the oil pressure sensor for until there is actually oil pressure to monitor; 
 *  and it will also send ouput pin A13 high - reversing the linear actuator until the throttle triggers limit switch 1 (LS1, on input pin A1). The tractor then can be started  
 *  When the implement has completed its watering cycling the arm will trigger the pump motor to shut down. This is between 800-900 feet away from the tractor.
 *  at the same time a long range RF transmitter will be triggered, it's receiver mounted at the tractor. The receiver will use this signal to send a high signal to input A0 (RFTrig). That will call the 
 *  "Shutdown" loop to initiate and will include a time variable. If Shutdown is called from either pins A4 or A5, the included time variable will be 0; if it is called from pin A0, it will be 180,000 ms (3 min). 
 *  Shutdown: The output on pin A12 (DCFwd) will go high, activating the DC motor controller forward trigger until a high signal is received from tripping the limit switch LS1 on input pin A1. the program will 
 *  then use the delay command to pause all operations for the amount specified in the attached variable. Dependant upon the source of the trigger, it will either pause for 0 milliseconds, or 180,000 milliseconds
 *  after which time it will once again activate output pin 12 (DCFwd) and hold it high until a high signal is received on input pin A2 (LS2), caused by contacting the limit switch (LS2) located at the throttle's
 *  off position. And finally, the Mega will release the high level that was being held on output pin 14, Igntn, turning off the tractor's ignition.
 *  In case of a malfunction or system lockup, or if the tractor was not started by the time the indicator LED was tuned off, a low level reset can be initiated via pressing the reset button connected to input 
 *  pin A3 (Rst) which will close the loop between GND and RESET on the board until a low level reset sequence is initiated.
  */

#include "millisDelay.h" 
millisDelay ledDelay; // delay for led
millisDelay msoilDelay; // delay for msoil read
 const int RFTrig = 0; // RF input from pump on pin A0 
 const int LS1 = 1; // Limit switch at idle position on pin A1
 const int LS2 = 2; // Limit switch at off position on pin A2
 const int Rst = 3; // Reset sequence to ignore Murphy oil input for 2 min initiated on pin A3
 const int MSTmp = 4; // Murphy switch high temperature on pin A4
 const int MSOil = 5; // Murphy switch oil pressure (low) on pin A5
 const int DCFwd = 12; // Ouput to activate DC motor controller forward on pin A12
 const int DCBwd = 13; // Output to activate DC motor controller reverse on pin A13
 const int Igntn = 14; // Output to activate tractor power kill relay on pin A14
 const int LEDStat = 15; // Output to activate LED (1min) to indicate ignoring Murphy oil (2min) start procedure
 int rftrig = 0; // variable for A0 read value
 int ls1 = 0; // variable for A1 read value
 int ls2 = 0; // variable for A2 read value
 int rst = 0; // variable for A3 read value
 int mstmp = 0; // variable for A4 read value
 int msoil = 0; //variable for A5 read value

void setup() {
  // put your setup code here, to run once:
pinMode(RFTrig, INPUT); // set pin A0 as input
pinMode(LS1, INPUT); //set pin A1 as input
pinMode(LS2, INPUT); // set pin A2 as input
pinMode(Rst, INPUT); // set pin A3 as input
pinMode(MSTmp, INPUT); // set pin A4 as input
pinMode(MSOil, INPUT); // set pin A5 as input
pinMode(DCFwd, OUTPUT); // set pin A12 as output
pinMode(DCBwd, OUTPUT); // set pin A13 as output
pinMode(Igntn, OUTPUT); // set pin A14 as output
pinMode(LEDStat, OUTPUT); // set pin A15 as output
digitalWrite(Igntn, HIGH);  
digitalWrite(LEDStat, HIGH);
ledDelay.start(60000);  // start a 60sec delay for the "ok to start LED"
do {         
  digitalWrite(DCBwd, HIGH); // activate the dc motor in reverse to return idle arm to idle/start position
  } while (ls1 = LOW); // for as long as limit switch 1 is low/off and stop when limit switch 1 is hit
msoilDelay.start(120000); // start a 120sec delay

}
void loop() {
  // put your main code here, to run repeatedly:
 // check if the LED timer has timed out
  if (ledDelay.justFinished()) {
    digitalWrite(LEDStat, LOW); // turn led off
  } 
 // check if MSOil read delay has timed out
  if (msoilDelay.justFinished()) {
    msoil=digitalRead(MSOil); // Start reading data from the oil pressure input
  }
rftrig=digitalRead(RFTrig); // start monitoring the RFTrig input
ls1=digitalRead(LS1);  // Start monitoring Limit Switch 1
ls2=digitalRead(LS2); // Start monitoring Limit Switch 2
rst=digitalRead(Rst); // Start monitoring the reset switch
mstmp=digitalRead(MSTmp); // Start monitoring the tractor operating temperature (input signal is sent on high temp)


  }

void shutdown()  {
  // create function "shutdown"
do {
  digitalWrite(DCFwd, HIGH); // activate the DC motor forward (reducing RPM)
  } while (ls1 = LOW); // until limit switch 1 (idle) is triggered
delay(???) /*here is where i am stuck
* I want a variable named "source" to be carried into the function shutdown. "shutdown" would be called 1 of 3 ways. 1) a HIGH on RFTrig; 2) a HIGH on MSTmp; 3) a HIGH on MSOil, after the initial 2 min timer
* ran out. So here's the thing... if it was called by RFTrig, I want the delay to be 180000ms; but if it is called by either of the other 2 triggered inputs I want the delay to be 0. so obviously I need to create 
* int source in my setup, but i have no idea how to define/identify it, or how to have that variable carry over into "shutdown". HELP
 */
digitalWrite(Igntn, LOW; // shuts off the key
}

}

  

I don't have a circuit drawing at the moment and it is a reasonably involved setup. I will include on with the code once it is all done, but for now time is of the essence and the circuit has 0 bearing on my coding question. I just want to assign a variable to identify which of the 3 sources the call came from and set 1 condition depending on that variable. Thanks.

An alternative approach is to pass a parameter to the shutdown function to specify the length of the delay. You can have three if's in loop that check the three conditions and each will call shutdown.

ok, so could i do it like:
if 1 = HIGH;
then int source = 180000;
if 2 = HIGH;
then int source = 0;
if 3 = HIGH;
then int source = 0;

shutdown()
--commands--;
delay(source);

would that work??

Nearly. Make source a global and lose the int declarations in your code.

Const int = sometning created at start never to change
Int = a variable that changes in the program.

Example:

const int oil_pressure_sensor ;
Int oilPressure

I would offer that some sort of sleep or disconnect be used.
A constantly connected heater. Aka lm7805 will suck the life out of batteries.

A schematic, while nice to see, is mostly needed for connection problems.

It seems your questions are software related.

If RFTrig signal goes low
Start timer

When timer ends
ShutDown = 1

If Mstemp or msoil = 0
Shutdown = 1

In the output section of your. Code

DigiatWrite (motor_run,shutdown)

As a comment. Your remote should have a keep_alive signal.

If there is no signal then one can assume the remote has stopped operating.

And no ShutDown signal will come

ok, well the 7805 will only be powering the mega board and for supplying a reference voltage across relays, nothing more. So when the circuit isn't being used all that it should draw is whatever the mega 2560 draws when in sleep mode.

the remote will have a 12V lithium battery on it. Consider how long 2 AA batteries keep your garage door opener working. This is the exact same thing, but on a 12V battery. And just for safe measure, I am connecting a solar panel and charging circuit to the battery, along with a battery LED test indicator so that it can be checked every time it is used. I will supply a second battery and tell my brother that if the led's are at half or less then he should change batteries. That should solve that.

But back to this issue at hand... I'm a little bit confused with the feedback that I received. I wrote a little bit more code, but being an ignorant novice i know the syntax is wrong. Am I on the right track here though?

/* Irrigation tractor shutdown system
 *  By: Craig Hatzel
 *  May 20, 2021
 *  The purpose for this code is to shut off a tractor that is being used to run an irrigation system via its PTO drive. At startup the Mega2560 will immediately send ouput pin A14 (Igntn) high - closing the NO 
 *  IGNITION relay, connected in parallel with the ignition switch; send output pin A15 (LEDStat) high for 1 min - activating the "Ready to Start" indicator LED; begin a 120,000 millisecond timer (2 min), at 
 *  the end of which it will initialize the monitoring (digitalread) of input pin A5 (MSOil) - delaying the emergency shutdown use of the oil pressure sensor for until there is actually oil pressure to monitor; 
 *  and it will also send ouput pin A13 high - reversing the linear actuator until the throttle triggers limit switch 1 (LS1, on input pin A1). The tractor then can be started  
 *  When the implement has completed its watering cycling the arm will trigger the pump motor to shut down. This is between 800-900 feet away from the tractor.
 *  at the same time a long range RF transmitter will be triggered, it's receiver mounted at the tractor. The receiver will use this signal to send a high signal to input A0 (RFTrig). That will call the 
 *  "Shutdown" loop to initiate and will include a time variable. If Shutdown is called from either pins A4 or A5, the included time variable will be 0; if it is called from pin A0, it will be 180,000 ms (3 min). 
 *  Shutdown: The output on pin A12 (DCFwd) will go high, activating the DC motor controller forward trigger until a high signal is received from tripping the limit switch LS1 on input pin A1. the program will 
 *  then use the delay command to pause all operations for the amount specified in the attached variable. Dependant upon the source of the trigger, it will either pause for 0 milliseconds, or 180,000 milliseconds
 *  after which time it will once again activate output pin 12 (DCFwd) and hold it high until a high signal is received on input pin A2 (LS2), caused by contacting the limit switch (LS2) located at the throttle's
 *  off position. And finally, the Mega will release the high level that was being held on output pin 14, Igntn, turning off the tractor's ignition.
 *  In case of a malfunction or system lockup, or if the tractor was not started by the time the indicator LED was tuned off, a low level reset can be initiated via pressing the reset button connected to input 
 *  pin A3 (Rst) which will close the loop between GND and RESET on the board until a low level reset sequence is initiated.
  */

#include "millisDelay.h" 
millisDelay ledDelay; // delay for led
millisDelay msoilDelay; // delay for msoil read
 const int RFTrig = 0; // RF input from pump on pin A0 
 const int LS1 = 1; // Limit switch at idle position on pin A1
 const int LS2 = 2; // Limit switch at off position on pin A2
 const int Rst = 3; // Reset sequence to ignore Murphy oil input for 2 min initiated on pin A3
 const int MSTmp = 4; // Murphy switch high temperature on pin A4
 const int MSOil = 5; // Murphy switch oil pressure (low) on pin A5
 const int DCFwd = 12; // Ouput to activate DC motor controller forward on pin A12
 const int DCBwd = 13; // Output to activate DC motor controller reverse on pin A13
 const int Igntn = 14; // Output to activate tractor power kill relay on pin A14
 const int LEDStat = 15; // Output to activate LED (1min) to indicate ignoring Murphy oil (2min) start procedure
 int rftrig = 0; // variable for A0 read value
 int ls1 = 0; // variable for A1 read value
 int ls2 = 0; // variable for A2 read value
 int rst = 0; // variable for A3 read value
 int mstmp = 0; // variable for A4 read value
 int msoil = 0; //variable for A5 read value

void setup() {
  // put your setup code here, to run once:
pinMode(RFTrig, INPUT); // set pin A0 as input
pinMode(LS1, INPUT); //set pin A1 as input
pinMode(LS2, INPUT); // set pin A2 as input
pinMode(Rst, INPUT); // set pin A3 as input
pinMode(MSTmp, INPUT); // set pin A4 as input
pinMode(MSOil, INPUT); // set pin A5 as input
pinMode(DCFwd, OUTPUT); // set pin A12 as output
pinMode(DCBwd, OUTPUT); // set pin A13 as output
pinMode(Igntn, OUTPUT); // set pin A14 as output
pinMode(LEDStat, OUTPUT); // set pin A15 as output
digitalWrite(Igntn, HIGH);  
digitalWrite(LEDStat, HIGH);
ledDelay.start(60000);  // start a 60sec delay for the "ok to start LED"
do {         
  digitalWrite(DCBwd, HIGH); // activate the dc motor in reverse to return idle arm to idle/start position
  } while (ls1 = LOW); // for as long as limit switch 1 is low/off and stop when limit switch 1 is hit
msoilDelay.start(120000); // start a 120sec delay

}
void loop() {
  // put your main code here, to run repeatedly:
 // check if the LED timer has timed out
  if (ledDelay.justFinished()) {
    digitalWrite(LEDStat, LOW); // turn led off
  } 
 // check if MSOil read delay has timed out
  if (msoilDelay.justFinished()) {
    msoil=digitalRead(MSOil); // Start reading data from the oil pressure input
  }
rftrig=digitalRead(RFTrig); // start monitoring the RFTrig input
ls1=digitalRead(LS1);  // Start monitoring Limit Switch 1
ls2=digitalRead(LS2); // Start monitoring Limit Switch 2
rst=digitalRead(Rst); // Start monitoring the reset switch
mstmp=digitalRead(MSTmp); // Start monitoring the tractor operating temperature (input signal is sent on high temp)
if (rftrig = HIGH);
then int source = 180000;
if mstmp = HIGH;
then int source = 0;
if msoil = HIGH;
then source = 0;
shutdown ()
  }

void shutdown()  {
  // create function "shutdown"
do {
  digitalWrite(DCFwd, HIGH); // activate the DC motor forward (reducing RPM)
  } while (ls1 = LOW); // until limit switch 1 (idle) is triggered
delay(source) 
digitalWrite(Igntn, LOW; // shuts off the key
}

}

  

No. Declare source after this line.
int msoil = 0; //variable for A5 read value

ok, here is what it looks like now. but it won't pass the verifier. it keeps saying expected unqualified-id before "if"

/* Irrigation tractor shutdown system
 *  By: Craig Hatzel
 *  May 20, 2021
 *  The purpose for this code is to shut off a tractor that is being used to run an irrigation system via its PTO drive. At startup the Mega2560 will immediately send ouput pin A14 (Igntn) high - closing the NO 
 *  IGNITION relay, connected in parallel with the ignition switch; send output pin A15 (LEDStat) high for 1 min - activating the "Ready to Start" indicator LED; begin a 120,000 millisecond timer (2 min), at 
 *  the end of which it will initialize the monitoring (digitalread) of input pin A5 (MSOil) - delaying the emergency shutdown use of the oil pressure sensor for until there is actually oil pressure to monitor; 
 *  and it will also send ouput pin A13 high - reversing the linear actuator until the throttle triggers limit switch 1 (LS1, on input pin A1). The tractor then can be started  
 *  When the implement has completed its watering cycling the arm will trigger the pump motor to shut down. This is between 800-900 feet away from the tractor.
 *  at the same time a long range RF transmitter will be triggered, it's receiver mounted at the tractor. The receiver will use this signal to send a high signal to input A0 (RFTrig). That will call the 
 *  "Shutdown" loop to initiate and will include a time variable. If Shutdown is called from either pins A4 or A5, the included time variable will be 0; if it is called from pin A0, it will be 180,000 ms (3 min). 
 *  Shutdown: The output on pin A12 (DCFwd) will go high, activating the DC motor controller forward trigger until a high signal is received from tripping the limit switch LS1 on input pin A1. the program will 
 *  then use the delay command to pause all operations for the amount specified in the attached variable. Dependant upon the source of the trigger, it will either pause for 0 milliseconds, or 180,000 milliseconds
 *  after which time it will once again activate output pin 12 (DCFwd) and hold it high until a high signal is received on input pin A2 (LS2), caused by contacting the limit switch (LS2) located at the throttle's
 *  off position. And finally, the Mega will release the high level that was being held on output pin 14, Igntn, turning off the tractor's ignition.
 *  In case of a malfunction or system lockup, or if the tractor was not started by the time the indicator LED was tuned off, a low level reset can be initiated via pressing the reset button connected to input 
 *  pin A3 (Rst) which will close the loop between GND and RESET on the board until a low level reset sequence is initiated.
  */

#include "millisDelay.h" 
millisDelay ledDelay; // delay for led
millisDelay msoilDelay; // delay for msoil read
 const int RFTrig = 0; // RF input from pump on pin A0 
 const int LS1 = 1; // Limit switch at idle position on pin A1
 const int LS2 = 2; // Limit switch at off position on pin A2
 const int Rst = 3; // Reset sequence to ignore Murphy oil input for 2 min initiated on pin A3
 const int MSTmp = 4; // Murphy switch high temperature on pin A4
 const int MSOil = 5; // Murphy switch oil pressure (low) on pin A5
 const int DCFwd = 12; // Ouput to activate DC motor controller forward on pin A12
 const int DCBwd = 13; // Output to activate DC motor controller reverse on pin A13
 const int Igntn = 14; // Output to activate tractor power kill relay on pin A14
 const int LEDStat = 15; // Output to activate LED (1min) to indicate ignoring Murphy oil (2min) start procedure
 int rftrig = 0; // variable for A0 read value
 int ls1 = 0; // variable for A1 read value
 int ls2 = 0; // variable for A2 read value
 int rst = 0; // variable for A3 read value
 int mstmp = 0; // variable for A4 read value
 int msoil = 0; //variable for A5 read value

if (rftrig = HIGH); // if the source of the "shutdown" call was rftrig,
then int source = 180000; // then variable source will be 3 min
else if mstmp = HIGH; // if the source of the "shutdown" call was mstmp,
then int source = 0; // then variable source will be 0
else if msoil = HIGH; // if the source of the "shutdown" call was msoil,
then source = 0; // then variable source will be 0

void setup() {
  // put your setup code here, to run once:
pinMode(RFTrig, INPUT); // set pin A0 as input
pinMode(LS1, INPUT); //set pin A1 as input
pinMode(LS2, INPUT); // set pin A2 as input
pinMode(Rst, INPUT); // set pin A3 as input
pinMode(MSTmp, INPUT); // set pin A4 as input
pinMode(MSOil, INPUT); // set pin A5 as input
pinMode(DCFwd, OUTPUT); // set pin A12 as output
pinMode(DCBwd, OUTPUT); // set pin A13 as output
pinMode(Igntn, OUTPUT); // set pin A14 as output
pinMode(LEDStat, OUTPUT); // set pin A15 as output
digitalWrite(Igntn, HIGH);  
digitalWrite(LEDStat, HIGH);
ledDelay.start(60000);  // start a 60sec delay for the "ok to start LED"
do {         
  digitalWrite(DCBwd, HIGH); // activate the dc motor in reverse to return idle arm to idle/start position
  } while (ls1 = LOW); // for as long as limit switch 1 is low/off and stop when limit switch 1 is hit
msoilDelay.start(120000); // start a 120sec delay

}
void loop() {
  // put your main code here, to run repeatedly:
 // check if the LED timer has timed out
  if (ledDelay.justFinished()) {
    digitalWrite(LEDStat, LOW); // turn led off
  } 
 // check if MSOil read delay has timed out
  if (msoilDelay.justFinished()) {
    msoil=digitalRead(MSOil); // Start reading data from the oil pressure input
  }
rftrig=digitalRead(RFTrig); // start monitoring the RFTrig input
ls1=digitalRead(LS1);  // Start monitoring Limit Switch 1
ls2=digitalRead(LS2); // Start monitoring Limit Switch 2
rst=digitalRead(Rst); // Start monitoring the reset switch
mstmp=digitalRead(MSTmp); // Start monitoring the tractor operating temperature (input signal is sent on high temp)

shutdown ()
  }

void shutdown()  {
  // create function "shutdown"
do {
  digitalWrite(DCFwd, HIGH); // activate the DC motor forward (reducing RPM)
  } while (ls1 = LOW); // until limit switch 1 (idle) is triggered
delay(source) 
do {
  digitalWrite (DCFwd, HIGH) // activate the motor again, moving from idle to off
  } while (ls2 = LOW); // until limit switch 2 (off) is triggered
digitalWrite(Igntn, LOW; // shuts off the key
}

}

  

All that code needs to go back where it was. All you need up there is this:

int source = 0;

I tried that. It's possible that the variable part is working but there are problems with my syntax in the way I am trying to use my IF statement and I can't figure it out. I was reading about using alternatives but can't quite understand them. Can anyone give me a hand sorting this out, please?

/* Irrigation tractor shutdown system
 *  By: Craig Hatzel
 *  May 20, 2021
 *  The purpose for this code is to shut off a tractor that is being used to run an irrigation system via its PTO drive. At startup the Mega2560 will immediately send ouput pin A14 (Igntn) high - closing the NO 
 *  IGNITION relay, connected in parallel with the ignition switch; send output pin A15 (LEDStat) high for 1 min - activating the "Ready to Start" indicator LED; begin a 120,000 millisecond timer (2 min), at 
 *  the end of which it will initialize the monitoring (digitalread) of input pin A5 (MSOil) - delaying the emergency shutdown use of the oil pressure sensor for until there is actually oil pressure to monitor; 
 *  and it will also send ouput pin A13 high - reversing the linear actuator until the throttle triggers limit switch 1 (LS1, on input pin A1). The tractor then can be started  
 *  When the implement has completed its watering cycling the arm will trigger the pump motor to shut down. This is between 800-900 feet away from the tractor.
 *  at the same time a long range RF transmitter will be triggered, it's receiver mounted at the tractor. The receiver will use this signal to send a high signal to input A0 (RFTrig). That will call the 
 *  "Shutdown" loop to initiate and will include a time variable. If Shutdown is called from either pins A4 or A5, the included time variable will be 0; if it is called from pin A0, it will be 180,000 ms (3 min). 
 *  Shutdown: The output on pin A12 (DCFwd) will go high, activating the DC motor controller forward trigger until a high signal is received from tripping the limit switch LS1 on input pin A1. the program will 
 *  then use the delay command to pause all operations for the amount specified in the attached variable. Dependant upon the source of the trigger, it will either pause for 0 milliseconds, or 180,000 milliseconds
 *  after which time it will once again activate output pin 12 (DCFwd) and hold it high until a high signal is received on input pin A2 (LS2), caused by contacting the limit switch (LS2) located at the throttle's
 *  off position. And finally, the Mega will release the high level that was being held on output pin 14, Igntn, turning off the tractor's ignition.
 *  In case of a malfunction or system lockup, or if the tractor was not started by the time the indicator LED was tuned off, a low level reset can be initiated via pressing the reset button connected to input 
 *  pin A3 (Rst) which will close the loop between GND and RESET on the board until a low level reset sequence is initiated.
  */

#include "millisDelay.h" 
millisDelay ledDelay; // delay for led
millisDelay msoilDelay; // delay for msoil read
 const int RFTrig = 0; // RF input from pump on pin A0 
 const int LS1 = 1; // Limit switch at idle position on pin A1
 const int LS2 = 2; // Limit switch at off position on pin A2
 const int Rst = 3; // Reset the Mega 2560, re-initializing the setup routine
 const int MSTmp = 4; // Murphy switch high temperature on pin A4
 const int MSOil = 5; // Murphy switch oil pressure (low) on pin A5
 const int DCFwd = 12; // Ouput to activate DC motor controller forward on pin A12
 const int DCBwd = 13; // Output to activate DC motor controller reverse on pin A13
 const int Igntn = 14; // Output to activate tractor power kill relay on pin A14
 const int LEDStat = 15; // Output to activate LED (1min) to indicate ignoring Murphy oil (2min) start procedure
 int rftrig = 0; // variable for A0 read value
 int ls1 = 0; // variable for A1 read value
 int ls2 = 0; // variable for A2 read value
 int rst = 0; // variable for A3 read value
 int mstmp = 0; // variable for A4 read value
 int msoil = 0; //variable for A5 read value
 int source = 0; // variable for length of delay at idle during "shutdown"


void setup() {
  // put your setup code here, to run once:
pinMode(RFTrig, INPUT); // set pin A0 as input
pinMode(LS1, INPUT); //set pin A1 as input
pinMode(LS2, INPUT); // set pin A2 as input
pinMode(Rst, INPUT); // set pin A3 as input
pinMode(MSTmp, INPUT); // set pin A4 as input
pinMode(MSOil, INPUT); // set pin A5 as input
pinMode(DCFwd, OUTPUT); // set pin A12 as output
pinMode(DCBwd, OUTPUT); // set pin A13 as output
pinMode(Igntn, OUTPUT); // set pin A14 as output
pinMode(LEDStat, OUTPUT); // set pin A15 as output
digitalWrite(Igntn, HIGH);  
digitalWrite(LEDStat, HIGH);
ledDelay.start(60000);  // start a 60sec delay for the "ok to start LED"
do {         
  digitalWrite(DCBwd, HIGH); // activate the dc motor in reverse to return idle arm to idle/start position
  } while (ls1 = LOW); // for as long as limit switch 1 is low/off and stop when limit switch 1 is hit
msoilDelay.start(120000); // start a 120sec delay

}
void loop() {
  // put your main code here, to run repeatedly:
 // check if the LED timer has timed out
  if (ledDelay.justFinished()) {
    digitalWrite(LEDStat, LOW); // turn led off
  } 
 // check if MSOil read delay has timed out
  if (msoilDelay.justFinished()) {
    msoil=digitalRead(MSOil); // Start reading data from the oil pressure input
  }
rftrig=digitalRead(RFTrig); // start monitoring the RFTrig input
ls1=digitalRead(LS1);  // Start monitoring Limit Switch 1
ls2=digitalRead(LS2); // Start monitoring Limit Switch 2
rst=digitalRead(Rst); // Start monitoring the reset switch
mstmp=digitalRead(MSTmp); // Start monitoring the tractor operating temperature (input signal is sent on high temp)
if (rftrig = HIGH); // if the source of the "shutdown" call was rftrig,
  int source = 180000; // then variable source will be 3 min
  
  if (mstmp = HIGH); // if the source of the "shutdown" call was mstmp,
  int source = 0; // then variable source will be 0

  if (msoil = HIGH); // if the source of the "shutdown" call was msoil,
  source = 0; // then variable source will be 0

shutdown ()
  }

void shutdown()  {
  // create function "shutdown"
do {
  digitalWrite(DCFwd, HIGH); // activate the DC motor forward (reducing RPM)
  } while (ls1 = LOW); // until limit switch 1 (idle) is triggered
delay(source) 
do {
  digitalWrite (DCFwd, HIGH) // activate the motor again, moving from idle to off
  } while (ls2 = LOW); // until limit switch 2 (off) is triggered
digitalWrite(Igntn, LOW; // shuts off the key
}

}

  

You managed to cram quite a few bugs into a little section of code :wink:

Try this:

  if (rftrig == HIGH) // if the source of the "shutdown" call was rftrig,
    source = 180000; // then variable source will be 3 min
  
  if (mstmp == HIGH) // if the source of the "shutdown" call was mstmp,
    source = 0; // then variable source will be 0

  if (msoil == HIGH) // if the source of the "shutdown" call was msoil,
    source = 0; // then variable source will be 0
if(rftrig == HIGH || mstmp == HIGH || msoil == HIGH)
  shutdown ()

shutdown() was not declared in this scope error. I have it exactly as you've written it.

oops. needs a semicolon on the end.

I tried that. I also got rid of the space between shutdown and the brackets. It just doesn't let that error go away

/* Irrigation tractor shutdown system
 *  By: Craig Hatzel
 *  May 20, 2021
 *  The purpose for this code is to shut off a tractor that is being used to run an irrigation system via its PTO drive. At startup the Mega2560 will immediately send ouput pin A14 (Igntn) high - closing the NO 
 *  IGNITION relay, connected in parallel with the ignition switch; send output pin A15 (LEDStat) high for 1 min - activating the "Ready to Start" indicator LED; begin a 120,000 millisecond timer (2 min), at 
 *  the end of which it will initialize the monitoring (digitalread) of input pin A5 (MSOil) - delaying the emergency shutdown use of the oil pressure sensor for until there is actually oil pressure to monitor; 
 *  and it will also send ouput pin A13 high - reversing the linear actuator until the throttle triggers limit switch 1 (LS1, on input pin A1). The tractor then can be started  
 *  When the implement has completed its watering cycling the arm will trigger the pump motor to shut down. This is between 800-900 feet away from the tractor.
 *  at the same time a long range RF transmitter will be triggered, it's receiver mounted at the tractor. The receiver will use this signal to send a high signal to input A0 (RFTrig). That will call the 
 *  "Shutdown" loop to initiate and will include a time variable. If Shutdown is called from either pins A4 or A5, the included time variable will be 0; if it is called from pin A0, it will be 180,000 ms (3 min). 
 *  Shutdown: The output on pin A12 (DCFwd) will go high, activating the DC motor controller forward trigger until a high signal is received from tripping the limit switch LS1 on input pin A1. the program will 
 *  then use the delay command to pause all operations for the amount specified in the attached variable. Dependant upon the source of the trigger, it will either pause for 0 milliseconds, or 180,000 milliseconds
 *  after which time it will once again activate output pin 12 (DCFwd) and hold it high until a high signal is received on input pin A2 (LS2), caused by contacting the limit switch (LS2) located at the throttle's
 *  off position. And finally, the Mega will release the high level that was being held on output pin 14, Igntn, turning off the tractor's ignition.
 *  In case of a malfunction or system lockup, or if the tractor was not started by the time the indicator LED was tuned off, a low level reset can be initiated via pressing the reset button connected to input 
 *  pin A3 (Rst) which will close the loop between GND and RESET on the board until a low level reset sequence is initiated.
  */

#include "millisDelay.h" 
millisDelay ledDelay; // delay for led
millisDelay msoilDelay; // delay for msoil read
 const int RFTrig = 0; // RF input from pump on pin A0 
 const int LS1 = 1; // Limit switch at idle position on pin A1
 const int LS2 = 2; // Limit switch at off position on pin A2
 const int Rst = 3; // Reset the Mega 2560, re-initializing the setup routine
 const int MSTmp = 4; // Murphy switch high temperature on pin A4
 const int MSOil = 5; // Murphy switch oil pressure (low) on pin A5
 const int DCFwd = 12; // Ouput to activate DC motor controller forward on pin A12
 const int DCBwd = 13; // Output to activate DC motor controller reverse on pin A13
 const int Igntn = 14; // Output to activate tractor power kill relay on pin A14
 const int LEDStat = 15; // Output to activate LED (1min) to indicate ignoring Murphy oil (2min) start procedure
 int rftrig = 0; // variable for A0 read value
 int ls1 = 0; // variable for A1 read value
 int ls2 = 0; // variable for A2 read value
 int rst = 0; // variable for A3 read value
 int mstmp = 0; // variable for A4 read value
 int msoil = 0; //variable for A5 read value
 int source = 0; // variable for length of delay at idle during "shutdown"


void setup() {
  // put your setup code here, to run once:
pinMode(RFTrig, INPUT); // set pin A0 as input
pinMode(LS1, INPUT); //set pin A1 as input
pinMode(LS2, INPUT); // set pin A2 as input
pinMode(Rst, INPUT); // set pin A3 as input
pinMode(MSTmp, INPUT); // set pin A4 as input
pinMode(MSOil, INPUT); // set pin A5 as input
pinMode(DCFwd, OUTPUT); // set pin A12 as output
pinMode(DCBwd, OUTPUT); // set pin A13 as output
pinMode(Igntn, OUTPUT); // set pin A14 as output
pinMode(LEDStat, OUTPUT); // set pin A15 as output
digitalWrite(Igntn, HIGH);  
digitalWrite(LEDStat, HIGH);
ledDelay.start(60000);  // start a 60sec delay for the "ok to start LED"
do {         
  digitalWrite(DCBwd, HIGH); // activate the dc motor in reverse to return idle arm to idle/start position
  } while (ls1 = LOW); // for as long as limit switch 1 is low/off and stop when limit switch 1 is hit
msoilDelay.start(120000); // start a 120sec delay

}
void loop() {
  // put your main code here, to run repeatedly:
 // check if the LED timer has timed out
  if (ledDelay.justFinished()) {
    digitalWrite(LEDStat, LOW); // turn led off
  } 
 // check if MSOil read delay has timed out
  if (msoilDelay.justFinished()) {
    msoil=digitalRead(MSOil); // Start reading data from the oil pressure input
  }
rftrig=digitalRead(RFTrig); // start monitoring the RFTrig input
ls1=digitalRead(LS1);  // Start monitoring Limit Switch 1
ls2=digitalRead(LS2); // Start monitoring Limit Switch 2
rst=digitalRead(Rst); // Start monitoring the reset switch
mstmp=digitalRead(MSTmp); // Start monitoring the tractor operating temperature (input signal is sent on high temp)
if (rftrig = HIGH) // if the source of the "shutdown" call was rftrig,
  int source = 180000; // then variable source will be 3 min
  
  if (mstmp = HIGH) // if the source of the "shutdown" call was mstmp,
  int source = 0; // then variable source will be 0

  if (msoil = HIGH) // if the source of the "shutdown" call was msoil,
  source = 0; // then variable source will be 0
if(rftrig == HIGH || mstmp == HIGH || msoil == HIGH)
shutdown();

}  }

void shutdown()  {
  // create function "shutdown"
do {
  digitalWrite(DCFwd, HIGH); // activate the DC motor forward (reducing RPM)
  } while (ls1 = LOW); // until limit switch 1 (idle) is triggered
delay(source) 
do {
  digitalWrite (DCFwd, HIGH) // activate the motor again, moving from idle to off
  } while (ls2 = LOW); // until limit switch 2 (off) is triggered
digitalWrite(Igntn, LOW; // shuts off the key
}

}

  

At the end of loop you have two braces, but only one is needed.

}  }

Good catch!

what does warning: overflow implicit constant conversion [-Woverflow]
mean?