need help on programming a keypad (i'm still a total newbie)

i’m trying to rotate a stepper motor as many times & as fast as inserted on a 4x4 keypad like this

1 2 3 A
4 5 6 B
7 8 9 C

  • 0 # D

to prevent wrong inputs, i also included a 2x16 lcd to display the number inputted. here’s the process.

first, the lcd will prompt you to insert the number of rotations. input the number and press * to continue

then the lcd will prompt you to insert the speed (the lcd will display a distance instead of speed, since i will need slower speeds for shorter distances and vice versa). this time, using the letter buttons. likewise, press * to continue.

when you finish inputting the numbers, the motor rotate as many times & as fast as it needs to.

here’s my code.

#include <LiquidCrystal_I2C.h>
#include <Stepper.h>
#include <Keypad.h>
#include <Wire.h>

#define ROTATIONS 0
#define SPEED 1
#define RUN 2 

byte mode=ROTATIONS;

const int FullCycle = 200;
const int A = 60;
const int B = 120;
const int C = 180;
const int D = 240;
Stepper motor (FullCycle, 10, 11, 12, 13);

const byte ROWS = 4; 
const byte COLS = 4; 

char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {9, 8, 7, 6}; 
byte colPins[COLS] = {5, 4, 3, 2}; 

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 
LiquidCrystal_I2C lcd(0x21, 16, 2);

void setup(){
  lcd.init();
  lcd.backlight();
  Serial.begin(9600);
  pinMode(10,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(13,OUTPUT);
  }
  
void loop(){
  switch(mode)
  {
    case ROTATIONS:
      setrotations();
      break:
    case SPEED:
      setspeed();
      break:
    case RUN:
      run()
      break:
  }
}

void setrotations(){
  lcd.setCursor(0,0);
  lcd.print("Rotations:");
  
  char entry1 = customKeypad.getKey();
  
  if (entry1){
    Serial.println(entry1);
  }
    
  if (entry1=="*"){
    mode = SPEED;
  }
}

void setspeed(){
  lcd.setCursor(0,0);
  lcd.print("Distance");

  char entry2 = customKeypad.getKey();

  if (entry2){
    Serial.println(entry2);
  }

  if(entry2=="*"){
    mode = RUN;
  }
}

void run(){
  motor.setSpeed(entry2);
  motor.step(entry1*FullCycle);
}

here’s my questions:

  1. i’m planning on using # as a reset button. how can i program this?

  2. i always get these error messages whenever i try to upload it to the board. idk what it means, can anyone please help me through this?

Arduino: 1.8.4 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\max\Documents\Arduino\sketch_jan31a\sketch_jan31a.ino: In function 'void loop()':

sketch_jan31a:50: error: expected ';' before ':' token

       break:

            ^

sketch_jan31a:50: error: expected primary-expression before ':' token

sketch_jan31a:53: error: expected ';' before ':' token

       break:

            ^

sketch_jan31a:53: error: expected primary-expression before ':' token

C:\Users\max\Documents\Arduino\sketch_jan31a\sketch_jan31a.ino: In function 'void run()':

sketch_jan31a:91: error: 'entry2' was not declared in this scope

   motor.setSpeed(entry2);

                  ^

sketch_jan31a:92: error: 'entry1' was not declared in this scope

   motor.step(entry1*FullCycle);

              ^

exit status 1
expected ';' before ':' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
  1. the lcd always displays the numbers one by one. how do i resolve this?

thank you in advance to those who reply

2 What character should follow a break ?

UKHeliBob:
2 What character should follow a break ?

And the answer is what ?

‘break’ is a statement and should end in a semicolon.

You are displaying keys on the LCD but not saving any digits into a number to use later, like this:

  char key = customKeypad.getKey();
  
  if (key >= '0' && key <= '9') {
    Serial.println(key);
         NumberEntered = NumberEntered * 10 + (key - '0');
  }