Menu system/Switch case within a switchcase

Hi! i have a problem: i have this menu system, witch is controlled with a 4x4 keypad and a 16*2 LCD screen. The third Switch case (in the row) is not activated, by that i mean, the loop returns itself to the top, and restarts. What could be the solution? I tried to write it using if closes, but the result was the same. Thanks!
maybe it is easier like this:
the code:

#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const byte numRows= 4;
const byte numCols= 4;

char keymap[numRows][numCols]=
{
{‘1’, ‘2’, ‘3’, ‘A’},
{‘4’, ‘5’, ‘6’, ‘B’},
{‘7’, ‘8’, ‘9’, ‘C’},
{’*’, ‘0’, ‘#’, ‘D’}
};
byte rowPins[numRows] = {13,12,11,10};
byte colPins[numCols]= {9,8,7,6};

Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

int stepPin = 2;
int dirPin = 3;
int buttonPin = 4;

void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(buttonPin,INPUT);

lcd.setCursor(0,0);
lcd.print(“DIY Video Slider”);
lcd.setCursor(5,1);
lcd.print(“V 1.0”);
delay(5000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“BY:”);
lcd.setCursor(3,1);
lcd.print(“Jancsik Gergo”);
delay(5000);
lcd.clear();
}
void loop()
{
lcd.setCursor(0,0);
lcd.print(“Left-Right A”);
lcd.setCursor(0,1);
lcd.print(“Right-Left B”);

char Direction;
do
{
Direction = myKeypad.getKey();
} while (Direction == NO_KEY);

switch (Direction)
{
case ‘A’:
digitalWrite(dirPin, LOW);
break;
case ‘B’:
digitalWrite(dirPin, HIGH);
break;
}

lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Video Mode A”);
lcd.setCursor(0,1);
lcd.print(“Time Lapse B”);
char Mode;
do
{
Mode = myKeypad.getKey();
} while (Mode == NO_KEY);

switch (Mode)
{
case ‘A’:
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Select Speed “);
lcd.setCursor(0,1);
lcd.print(” 1 2 3 ");
int Speed;
do
{
Speed = myKeypad.getKey()-48;
} while (Speed == NO_KEY);

switch (Speed)
{
case 1:
Move(6000);
break;
case 2:
Move(3000);
break;
case 3:
Move(1000);
break;
}
}
case ‘B’:
break;
}
}
void Move(int Speed)
{
for(int Step=0;Step<=2500;Step++)
{
if(Step<400)
Speed=1500;
digitalWrite(stepPin, HIGH);
delayMicroseconds(Speed);
digitalWrite(stepPin, LOW);
delayMicroseconds(Speed);
}
}

V.1.2.ino (2.53 KB)

You have no break; on case 'A' so the code will always fall into case 'B'.

Is that a problem ?

thansks for the observation, but unfortunatley that didn t solved the problem, im still haveing tha same issue

My guess is that it’s something to do with the lines…

do {
  Speed = myKeypad.getKey()-48;
  } while (Speed == NO_KEY);

I am not familiar enough with the keypad library to know how it behaves, and i don’t have a keypad to test this code. Have you used the serial monitor to print the value of Speed? It’s likely that it doesn’t == NO_KEY, 1, 2 or 3, so none of the cases are executed, and that would explain why the if statements have the same result.

this was a smart idea! i wrote in each "do while" loop a Serial.print and the result was, as far as i understand that the second do while loop is not being executed. Serial monitor shows : AA-48

Jancsik_Gergo:
this was a smart idea!

Arduino debugging 101

it s complet bullshit, if i delete the do while loop of the Speed, evrything gose right. >:(

I solved it! The problem was that the Arduino or God knows what couldn t handle the initialization with int (number integr) and char (character). I changed the int to char and it works like a charm.