Elevator Code

void setup() {
  pinMode(44, INPUT); // limite sup
  pinMode(5, INPUT); // limite inf
  pinMode(7, INPUT); // porta 1
  pinMode(8, INPUT); // botao 1 Up
  pinMode(9, INPUT); // piso 1
  pinMode(10, INPUT); // porta 2
  pinMode(11, INPUT); // butão 2 Up
  pinMode(12, INPUT); // butao 2 down
  pinMode(13, INPUT); // piso 2
  pinMode(22, INPUT); // porta 3
  pinMode(24, INPUT); // butao 3 Up
  pinMode(26, INPUT); // butao 3 Down
  pinMode(28, INPUT); // piso 3
  pinMode(30, INPUT); // porta 4
  pinMode(32, INPUT); // butao 4 down
  pinMode(34, INPUT); // piso 4
  pinMode(36, INPUT); // piso 1 interior
  pinMode(38, INPUT); // piso 2 int
  pinMode(40, INPUT); // piso 3 int
  pinMode(42, INPUT); // piso 4 int
  pinMode(4, OUTPUT);

  pinMode(3, OUTPUT);


  Serial.begin(9600);
}


void loop() {

  int limU = digitalRead(44);
  int  limD = digitalRead(5);
  int pt1 = digitalRead(7);
  int bt1 = digitalRead(8);
  int p1 = digitalRead(9);
  int pt2 = digitalRead(10);
  int bt2U = digitalRead(11);
  int  bt2D = digitalRead(12);
  int  p2 = digitalRead(13);
  int pt3 = digitalRead(22);
  int bt3U = digitalRead(24);
  int bt3D = digitalRead(26);
  int p3 = digitalRead(28);
  int  pt4 = digitalRead(30);
  int  bt4D = digitalRead(32);
  int p4 = digitalRead(34);
  int btint1 = digitalRead(36);
  int btint2 = digitalRead(38);
  int btint3 = digitalRead(40);
  int  btint4 = digitalRead(42);


if(bt4D ==1) {
        while(limU != 1){
    digitalWrite(3,HIGH);
    Serial.println("PISO 4");
    digitalWrite(4,LOW);}}

THIS IS PROGRAM TO ELEVATOR BUT I CAN’T STOP DE MOTOR.

N CONSIGO PARAR O MOTOR.

First I only had the if but by the time I took the finger out of the bt4d it went to 0 and the engine stopped. Then I put the while, but then when it arrives at the limon but it does not stop.

I wanted to stop when you get to limU, so he can do another routine.

HELP PLS

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

There is nothing inside this while loop that will change the value of limU.

  while(limU != 1){
    digitalWrite(3,HIGH);
    Serial.println("PISO 4");
    digitalWrite(4,LOW);
}

if LimU is not 1, then it will loop forever. You need to finish your while loop by reading the value again

  while(limU != 1){
    digitalWrite(3,HIGH);
    Serial.println("PISO 4");
    digitalWrite(4,LOW);
    limU = digitalRead(44);
}
[code]