I created a header file and included it in the code where the other #includes are
#include "MyHeader.h"
I moved these defs to the header:-
#pragma once
// Arduino Digital I/O pin numbers for MEGA
//note: digital pins 30-45
//MEGA is a MUST for this project
enum {
Relay1 = 30, Relay2 = 31, Relay3 = 32, Relay4 = 33, Relay5 = 34, Relay6 = 35,
Relay7 = 36, Relay8 = 37, Relay9 = 38, Relay10 = 39, Relay11 = 40,
Relay12 = 41, Relay13 = 42, Relay14 = 43, Relay15 = 44, Relay16 = 45
};
enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };
enum class CrossingZoneState : uint8_t {
CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state
CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor
CROSSINGZONE_EXITING = 2 // train detected by the exit sensor, when sensor clears, state= Clear
};
//*-----( Declare Variables )-----*/
// hardware is an optocoupler 16 channel 12V relay
const uint8_t relays[] = { Relay1,Relay2,Relay3,Relay4,
Relay5,Relay6,Relay7,Relay8,
Relay9,Relay10,Relay11,Relay12,
Relay13,Relay14,Relay15,Relay16 };
enum { maxRelayCount = sizeof relays / sizeof relays[0] };
This is how Arduino and C++ have historically worked however I will be adding the new intelligence to allow a header to be avoided.