New to Arduino - how do I PROPERLY make(write) variables?

Hi everyone!
As I'm really new to this overwhelming world of Arduino, but I already started my project - it's too late to give up.

I would love some help on how to write 2 variables that would check after for example 7 rotations of my steppers if my object is all rolled up or not yet - I know in theory what it should do and I can follow the code so far, but when it comes to these endswitches and the code they need I'm lost.

Could someone be so kind to help me?

please! :smiley:
have a nice day!

IoanaCiora:
and I can follow the code so far, but when it comes to these endswitches and the code they need I'm lost.

You have not posted the code that you are trying to figure out and without that it is not possible to help.

...R

An "endswitch" is usually connected between a digital input pin and Ground.

Step 1: Pick an unused pin and assign it a name:

const byte EndSwitchPin = 8;

Step 2: In setup(), set the pinMode to INPUT_PULLUP:

   pinMode(EndSwitchPin, INPUT_PULLUP);

Step 3: In your code (loop() or some function called by loop()), check to see if the switch is triggered:

if (Retracting) {
    digitalWrite(RetractStepperDirectionPin, HIGH);  // Set stepper for retract
    if (digitalRead(EndSwitchPin) == HIGH) { // Not triggered yet
        digitalWrite(RetractStepperStepPin, HIGH);
        delay(1);
        digitalWrite(RetractStepperStepPin, LOW);
    } else {
        Retracting =false;
    }
}