user77556: I've tried this code below but it doesn't stop it just rapidly switch direction that it looks like it's trembling I think because it always reads the void startF/R thats why it's trembling .
I need help on how to completely stop the stepper if it reads both sensor LOW
if (sensLval== LOW || sensRval == LOW){
     steppStop(); 
}

this is my void loop code below
    void startF()
  {
    motor1.step(10, FORWARD,SINGLE);
    
  }

    void startR()
  {
    motor1.step(10, BACKWARD,SINGLE);
    
  }

    void steppStop(){
  motor1.step(0, BACKWARD, SINGLE);
 
 motor1.step(0, FORWARD, SINGLE);
}

 
    void loop() {
  sensRval=digitalRead(sensR);
  
sensLval=digitalRead(sensL);


  if (sensLval == LOW)

{
    startF();
  }
  
if (sensLval== LOW && sensRval == LOW)

{
     steppStop();
  }

  if (sensRval == LOW)

{
    startR();
  }
  
  
  
}


user8583: Isolate your conditions.
You currently check for:

Both sensors LOW at the same time and
Either sensor LOW on its own

If both are low—don't check for either being LOW (which triggers startX.)
if (sensLval == LOW && sensRval == LOW) {
    steppStop();
} else if (sensLval == LOW) {
    startF();
} else if (sensRval == LOW) {
    startR();
}

There may be other considerations as well, but this is enough to get past that issue.

Unrelated, but consistent indentation goes a long way towards code readability and helping others be able to reason about code in general. When posting code it's a good idea to format your code as code, described here and when you are editing the question.

77556: <p>I've tried this code below but it doesn't stop it just rapidly switch direction that it looks like it's trembling I think because it always reads the void startF/R thats why it's trembling .</p>
<p>I need help on how to completely stop the stepper if it reads both sensor LOW</p>
<pre><code>if (sensLval== LOW || sensRval == LOW){
     steppStop(); 
}
</code></pre>
<p>this is my void loop code below</p>
<pre><code>    void startF()
  {
    motor1.step(10, FORWARD,SINGLE);
    
  }

    void startR()
  {
    motor1.step(10, BACKWARD,SINGLE);
    
  }

    void steppStop(){
  motor1.step(0, BACKWARD, SINGLE);
 
 motor1.step(0, FORWARD, SINGLE);
}

 
    void loop() {
  sensRval=digitalRead(sensR);
  
sensLval=digitalRead(sensL);


  if (sensLval == LOW)

{
    startF();
  }
  
if (sensLval== LOW &amp;&amp; sensRval == LOW)

{
     steppStop();
  }

  if (sensRval == LOW)

{
    startR();
  }
  
  
  
}
</code></pre>
 8583: <p>Isolate your conditions.</p>
<p>You currently check for:</p>
<ul>
<li><em>Both</em> sensors LOW at the same time <strong>and</strong></li>
<li><em>Either</em> sensor LOW on its own</li>
</ul>
<p>If <em>both</em> are low—don't check for <em>either</em> being LOW (which triggers <code>startX</code>.)</p>
<pre class="lang-cpp prettyprint-override"><code>if (sensLval == LOW &amp;&amp; sensRval == LOW) {
    steppStop();
} else if (sensLval == LOW) {
    startF();
} else if (sensRval == LOW) {
    startR();
}
</code></pre>
<p>There may be other considerations as well, but this is enough to get past that issue.</p>
<hr />
<p>Unrelated, but consistent indentation goes a long way towards code readability and helping others be able to reason about code in general. When posting code it's a good idea to format your code as code, <a href="https://arduino.stackexchange.com/editing-help">described here</a> and when you are editing the question.</p>
