#include <Stepper.h>
#include<LiquidCrystal_I2C.h>
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 8, 9);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Motor is ready");
lcd.setCursor(0, 1);
lcd.print(" to lunch");
delay(1000);
lcd.clear();
myStepper.setSpeed(900);
lcd.print("Please stay away !");
}
void loop() {
static int stepCount = 0;
static bool direction = true;
if (stepCount < stepsPerRevolution) {
myStepper.step(800); // Move 800 steps at a time
stepCount += 800; // Increment stepCount by the number of steps moved
} else {
// If the desired steps are reached, go back to 0
if (!direction) {
myStepper.step(-stepsPerRevolution); // Move back to 0
direction = !direction; // Change direction
}
stepCount = 0; // Reset step count
delay(700);
}
}