#include <Wire.h>
#include <Keypad.h>
#include <Stepper.h>
#include <LiquidCrystal_I2C.h>
//LCD:
LiquidCrystal_I2C lcd(0x27, 16, 2);
//KEYPAD:
const byte ROWS = 4;
const byte COLS = 4;
byte rowPins[ROWS] = {28, 30, 32, 34};
byte colPins[COLS] = {42, 44, 46, 48};
char keys[ROWS][COLS] = {
{'1', '2', '3', 'U'},
{'4', '5', '6', 'L'},
{'7', '8', '9', 'R'},
{'T', '0', 'S', 'D'}
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
//STEPPER MOTOR:
const int stepsPerRevolution = 800;
Stepper myStepper(stepsPerRevolution, 8, 9);
void setup() {
myStepper.setSpeed(10);
}
void loop() {
char key = keypad.getKey();
if (key != NO_KEY) {
if (key == 'L'){
for (int x = 0; stepsPerRevolution <= 800; x++ ){
myStepper.step(stepsPerRevolution);
}
}
else if (key == 'R'){
for (int x = 0; stepsPerRevolution >= 800; x-- ){
myStepper.step(-stepsPerRevolution);
}
}
}
}