I am having issue with my program.
I am working on a 3 floor elevator but right now I am debugging only the 1st floor routine and the elevator stop routine so I removed those parts.
[int Button1;
int Button2;
int Button3;
int Switch1;
int Switch2;
int Switch3;
int Led1=8;
int Led2=9;
int Led3=10;
int L2=11;
int L1=12;
int St=13;
int FLOOR;
int Busy;
int Speed;
void setup() {
pinMode(2, INPUT); // Button 1st floor
pinMode(3, INPUT); // Button 2nd floor
pinMode(4, INPUT); // Button 3rd floor
pinMode(5, INPUT); // position swith Elevator 1st floor
pinMode(6, INPUT); // position swith Elevator 2nd floor
pinMode(7, INPUT); // position swith Elevator 3rd floor
pinMode(8, OUTPUT); // led 1st floor
pinMode(9, OUTPUT); // led 2nd floor
pinMode(10, OUTPUT); // led 3rd floor
pinMode(11, OUTPUT); // Power switches
pinMode(12, OUTPUT); // Power motor exit 1
pinMode(13, OUTPUT); // Power motor exit 2
Busy = 0; // internal variable define if the elevator is workind and unable push buttons
FLOOR = 0;// internal variable determine on which floor the elevator is going
Speed= analogRead(0) / 4;
digitalWrite(St, LOW);
digitalWrite(Led1, LOW);
}
void loop() { //Define variables
Variables();
First_floor();
El_stop();
}
void Variables() { //Define variables
Button1 = digitalRead(2);
Button2 = digitalRead(3);
Button3 = digitalRead(4);
Switch1 = digitalRead(5);
Switch2 = digitalRead(6);
Switch3 = digitalRead(7);
}
void First_floor() { //1ST FLOOR
if (Busy = 0);
if (Button1 == HIGH)
{
digitalWrite(St, HIGH);
}
if ((Switch1 == LOW) and (Button1==HIGH))
{ digitalWrite(Led1, HIGH);
digitalWrite(L1, HIGH);
digitalWrite(L2, LOW);
Busy = 1;
FLOOR = 1;
}
}
void El_stop () { //El_stop
Serial.print(L1);
if (Busy = 1);
if ((FLOOR == 1) and (Switch1 == HIGH))
{ digitalWrite(St, LOW);
digitalWrite(L1, LOW);
digitalWrite(L2, LOW);
digitalWrite(Led1, LOW);
Busy = 0;
FLOOR = 0;
}
else if ((FLOOR == 2) and (Switch2 == HIGH))
{ digitalWrite(St, LOW);
digitalWrite(L1, LOW);
digitalWrite(L2, LOW);
Busy = 0;
FLOOR = 0;
}
else if ((FLOOR == 3) and (Switch3 == HIGH))
{ digitalWrite(St, LOW);
digitalWrite(L1, LOW);
digitalWrite(L2, LOW);
Busy = 0;
FLOOR = 0;
}
}]
In particular I am having issue with this part
[ if ((Switch1 == LOW) and (Button1==HIGH))
{ digitalWrite(Led1, HIGH);
digitalWrite(L1, HIGH);
digitalWrite(L2, LOW);
Busy = 1;
FLOOR = 1;]