Borocillicate pellet dispenser, having a problem with creating void subroutines

/* Many stepper motor projects need to move to exact positions.  This usually
  requires that the stepper motor library knows where the motor is before it
  makes its first move.  To achieve this automatically, you will use a
  Limit Switch that is pressed by the mechanism when the motor moves
  all-the-way to one end of its travel.  This procedure called "Homing", is
  executed when power is first applied.  A homing program moves the motor
  toward the limit switch until the switch is pressed, then resets the
  library so that the motor is now at position 0.

  Home automatically is easily done using one of these functions:
    moveToHomeInSteps()
    moveToHomeInRevolutions()
    moveToHomeInMillimeters()
*/

#include <SpeedyStepper.h>

const int LED_PIN = 13;
const int MOTOR_STEP_PIN = 4;
const int MOTOR_DIRECTION_PIN = 3;
const int EN = 2;
const int LIMIT_SWITCH_PIN = 5;
const int ROTATE = A3;  //COOLANT M8^/M9
const int HOMESW = A1;  //SPINDLE M3/M4^
SpeedyStepper stepper;

void setup()                 
{
  pinMode(LED_PIN, OUTPUT);
  pinMode(LIMIT_SWITCH_PIN, INPUT_PULLUP);
  Serial.begin(9600);
  stepper.connectToPins(MOTOR_STEP_PIN, MOTOR_DIRECTION_PIN);
}

void loop()              
{
  {
    if (digitalRead (HOMESW == HIGH))
    {
      homeRoutine();
    }
    else ;
  }
  digitalWrite (LED_PIN, HIGH);
}

void homeRoutine()           
{
  stepper.setStepsPerRevolution(200 * 1);    // 1x microstepping
  stepper.setSpeedInRevolutionsPerSecond(5);    //set speed
  stepper.setAccelerationInMillimetersPerSecondPerSecond(10.0);   //set accell
  const float homingSpeedInRevolutions = 1.0;   //find home
  const float maxHomingDistanceInRevolutions = 1;   // 1/2 revoution to fine home. If no find, then fault
  const int directionTowardHome = -1;        // direction to move toward limit switch: 1 goes positive direction, -1 backward

  if (stepper.moveToHomeInRevolutions(directionTowardHome, homingSpeedInRevolutions, maxHomingDistanceInRevolutions, LIMIT_SWITCH_PIN) != true)
  {
    while (true)
    {
      digitalWrite(LED_PIN, HIGH);    //LED fast forever indicating a problem
      delay(50);
      digitalWrite(LED_PIN, LOW);
      delay(50);
    }
  }

  delay(500);

  stepper.setCurrentPositionInMillimeters(0);
  while (true)
  {
    digitalWrite(LED_PIN, HIGH);  //I found home successfully
    delay(750);
    digitalWrite(LED_PIN, LOW);
    delay(750);
  }
  return;
}

void runtime ()
{
//runtime stuff here
}

Nano board question. I am trying to dispense borosilicate glass pellets using a stepper and have the home routine working fine but now would like to move it to a subroutine called void “homeRoutine ()” and another one called void “runtime()”, initiated by an input from another microcontroller running g-code. The wiring is correct and have verified that A1 is toggling.

I have not written the runtime one yet just focusing on the homing sequence, enabled when HOMESW goes HIGH. Every time it just goes to straight to my subroutine, no matter what the pin logic is. Why is this? Been googling this and hours spent trying things. I really want to understand what I am doing wrong.

if (digitalRead (HOMESW == HIGH))

Oops

const int HOMESW = A1;

See the problem?

Ha, ok, i got rid of the const, just made it int. It still jumps to the home though.

No, not the const, take another look at the digitalRead.

Which pin is it reading?

I'm embarrassed but not sure why yet. It is reading input A1.

const int HOMESW = A1; //SPINDLE M3/M4^

if (digitalRead (HOMESW == HIGH))

I'm missing something obvious?

No, it is reading pin zero

I don't get it.

digitalRead (HOMESW == HIGH)

HOMESW has the value A1, which is 15 on a Uno.
HIGH has the value 1.
15 is not equal to 1, so the result of the comparison is false.
false has the value zero, so digitalRead (0).

(How is all this COVID-related? Is “Borocillicate” anything like “borosilicate”?)

I never knew I couldn't define analog pins by their A#. This is from the forum:

Using A3 pin as OUTPUT example: Code: [Select]

pinMode(A3,OUTPUT);
digitalWrite(A3,HIGH);

but in UNO pinouts, yes, it shows pin 15. still confused

You’re reading pin zero.
Always.
Where’s the confusion?

Try if (digitalRead (HOMESW) == HIGH) instead.

How is this COVID-related?

How is all this COVID-related? "All this" is to finish my machine dispenses 3mm pellets in to test-tubes used in testing process before they get autoclaved. Takes too long by hand with million + orders. XYYZ axis + rotary and pellet pickup sorter. The Nano is just extended I/O since GRBL is limited.

Is "Borocillicate" anything like "borosilicate"? Yes, sorry for the spelling mistake, wont happen again.

if (digitalRead (HOMESW) == HIGH)

Are you saying "All this" is because I misplaced a parentheses?

Yup.

Well ((digitalRead =!hotdog) = it works now!)) Thanks!