#include <Stepper.h>
#include <LiquidCrystal_I2C.h>
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int pirPin = 2;
int motionDetected = 0;
void setup() {
pinMode(pirPin, INPUT);
myStepper.setSpeed(60);
lcd.init();
lcd.backlight();
lcd.print("Waiting for");
lcd.setCursor(0, 1);
lcd.print("motion...");
}
void loop() {
motionDetected = digitalRead(pirPin);
if (motionDetected == HIGH) {
lcd.clear();
lcd.print("Motion Detected");
myStepper.step(stepsPerRevolution);
lcd.clear();
lcd.print("Stepping...");
delay(2000);
lcd.clear();
lcd.print("Waiting for");
lcd.setCursor(0, 1);
lcd.print("motion...");
}
delay(500);
}