#include <Stepper.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
// change this to the number of steps on your motor
#define STEPS 100
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);
// the previous reading from the analog input
int previous = 0;
void setup() {
// set the speed of the motor to 30 RPMs
lcd.init();
lcd.backlight();
lcd.setCursor(1,0);
stepper.setSpeed(60);
pinMode(4, INPUT_PULLUP);
pinMode(2, INPUT);
Serial.begin(9600);
}
int HmSteps=0;
void loop() {
// get the sensor value
if(digitalRead(2)==HIGH){
Serial.print("Motion detected");
stepper.step(120);
HmSteps+=360;
}
/*if(digitalRead(2)==LOW){
stepper.step(-360);
}
*/
lcd.setCursor(0,0);
if(HmSteps==360){
lcd.print("Klopapier abnehmen");
}
// move a number of steps equal to the change in the
// sensor reading
}