Elevator
Elevator
Elevator
h>
#define btn3 6
#define btn2 7
#define btn1 8
#define led3 2
#define led2 3
#define led1 4
int i = 1;
Stepper small_stepper(100, 8, 10, 9, 11);
void setup() {
small_stepper.setSpeed(300);
Serial.begin(9600);
pinMode(btn3, INPUT_PULLUP);
pinMode(btn2, INPUT_PULLUP);
pinMode(btn1, INPUT_PULLUP);
pinMode(led3, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led1, OUTPUT);
digitalWrite(led3, LOW);
digitalWrite(led2, LOW);
digitalWrite(led1, LOW);
}
void updateLEDs() {
digitalWrite(led1, i == 1 ? HIGH : LOW);
digitalWrite(led2, i == 2 ? HIGH : LOW);
digitalWrite(led3, i == 3 ? HIGH : LOW);
}
void loop() {
Serial.print("Current Floor: ");
Serial.println(i);
delay(1000);
if (digitalRead(btn3) == HIGH) {
moveElevator(3);
}
if (digitalRead(btn2) == HIGH) {
moveElevator(2);
}
if (digitalRead(btn1) == HIGH) {
moveElevator(1);
}
}