Hall effect sensors with a mega 2560 and a relay module to power solenoids

Hi,

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

It will help.

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

[code]
// Identifying internal components and declaring as variables
//////////////////////////////////////////////////////////////

// Identify Input/Output Pins
const int firstHall=2; // select the input pin (sensor input)
const int firstCoil=5;// select pin for relay (relay output)

const int secondHall=3; // select the input pin (sensor input)
const int secondCoil=6; // select pin for relay (relay output)

const int thirdHall=21; // select the input pin (sensor input)
const int thirdCoil=7; // select pin for relay (relay output)

// Local Vairbales for execution
int hallState01 = 0; // Working variables for detecting Hall Effect Status
int hallState02 = 0;
int hallState03 = 0;

bool coilActive = false; // Stops loop from performing simultanious powering when Hall Effect is detected
int timingManager = 200; // The timing adjustment

// void setup - first function to initialize variables and start loop function
//////////////////////
void setup() {

// Identifying 
pinMode (firstHall, INPUT);
pinMode (secondHall, INPUT);
pinMode (thirdHall, INPUT);

pinMode (firstCoil, OUTPUT);
pinMode (secondCoil, OUTPUT);
pinMode (thirdCoil, OUTPUT);

Serial.begin (9600);

}

// Continuous action chain to detect Hall Effects and engage coils.
void loop() {

  // Check status of Hall Effects.
  hallState01 = digitalRead (firstHall);
  hallState02 = digitalRead (secondHall);
  hallState03 = digitalRead (thirdHall);

  // elseIf status for which Hall Effect 
  if (hallState01 == HIGH && !coilActive) { // Checks if Hall Effect is triggered and if there is no other coils active
    Serial.println ('The first Hall Effect has been triggered');
    coilActive = true; // local boolean set to true
    digitalWrite (firstCoil, HIGH); // power coil
    delay(timingManager); // delay by timing
    digitalWrite (firstCoil, LOW); // power off coil
    coilActive = false; // local boolean set to false
  } else if (hallState02 == HIGH && !coilActive) {
    Serial.println ('The second Hall Effect has been triggered');
    coilActive = true;
    digitalWrite (secondCoil, HIGH);
    delay(timingManager);
    digitalWrite (secondCoil, LOW);
  } else if (hallState03 == HIGH && !coilActive) {
    Serial.println ('The third Hall Effect has been triggered');
    coilActive = true;
    digitalWrite (thirdCoil, HIGH);
    delay(timingManager);
    digitalWrite (thirdCoil, LOW);
  } else {
    Serial.println ('A coil is active');
  }

}
[/code]