0

i don´t have any idea of coding but i´m doing a school exersice and it gives me the error of the title

while (distancia<200 && distancia>100);
{

  lcd.print("ALTO");
  delay(1000);
  lcd.clear();
  delay(1000);

  if(distancia<100)
  {

   break;
  }
}
 if(distancia<100);
  {

    lcd.print("INTRUSO EN");
    lcd.setCursor(0,1);
    lcd.print("LA PUERTA");
    tone(11,700,250);
    digitalWrite(8,HIGH);
    delay(500);
    lcd.clear();
    digitalWrite(8,LOW);
    delay(500);
}
}

It is in arduino and I want that it returns to the first while if (100<distancia) and that ("ALTO") disapear when (distancia<100), pls help, I have no idea of what I´m doing

1 Answers1

2

Here

  while (distancia<200 && distancia>100);
  --------------------------------------^

remove that semicolon, it terminates the while right there

    while (distancia<200 && distancia>100)
pm100
  • 48,078
  • 23
  • 82
  • 145
  • Thank you, the error disaperar but now I have another clue. When (distancia<100) it stills showing the ("ALTO") instead of ("INTRUSO EN") – Alan Alanis May 07 '22 at 16:05
  • @AlanAlanis In the code snippet, I see `distancia` checked four times in different places, but nowhere changed. How and where is `distancia` supposed to be changed? – heap underrun May 07 '22 at 16:47
  • You probably should ask a completely new question for this completely different problem. This question was about the `break;` and the problem ended up being that you put an errant `;` on the while () line unknowingly ending the loop before you expected. – drescherjm May 07 '22 at 16:57
  • @heapunderrun this is not the full code. distancia is not suposed to apear but ("ALTO") and ("INTRUSO EN") appears in an lcd display. distancia is from an ultrasonic distance sensor in the arduino one – Alan Alanis May 07 '22 at 17:00