#include "Keypad.h"
// include the library code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = A0, en = A1, d4 = A2, d5 = A3, d6 = A4, d7 = A5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
// For Arduino Microcontroller
byte rowPins[ROWS] = {12, 11, 10, 9};
byte colPins[COLS] = {8, 7, 6, 5};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
const int len_key = 5;
char master_key[len_key] = {'1','2','3','4','1'};
char attempt_key[len_key];
int z=0,previous_z;
short mode=0;
bool execute_flag=false;
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.setCursor(1, 0);
lcd.print("STEPPER CONTROLLER");
lcd.setCursor(1, 1);
lcd.print("MODE: ");
lcd.setCursor(1, 2);
lcd.print("MOVE: ");
}
void loop()
{
switch(mode)
{
case 0: {
lcd.setCursor(6, 1);
lcd.print("STEP ");
}
break;
case 1: {
lcd.setCursor(6, 1);
lcd.print("DEGREE");
}
break;
case 2: {
lcd.setCursor(6, 1);
lcd.print("TURN ");
}
break;
}
char key = keypad.getKey();
Serial.print(key);
if (key=='*')
{
mode++;
if(mode>=3)
mode=0;
}
if (key=='A')
{
mode=0;
}
if (key=='B')
{
mode=1;
}
if (key=='C')
{
mode=2;
}
if(mode==0)
{
}
}