Making a commande for my rebot

Hey guys ! I have an issue on how to make programme that allows me to enter value of x,y,z using a keypad . the idea is simple , i enter postions fisrt x then a validation and y then z but i couldn't make that happen especially i couldn't convert the caracters from string to int
For ex :
string a ={" 123 "} ----> int a = 123
Plz help

atoi (deprecated) or strtol.

(The Arduino has no datatype "string")

Done correctly you don't need to convert the whole value read from the keypad, rather you create the final integer as you go along.

1 - initialise the target int to zero
2 - read a key
3 - check that it is in the range '0' to '9'
4 - if it is in that range
4.1 - subtract '0' from it to turn it into a digit rather than a character representing a digit
4.2 - multiply the target int by 10
4.3 - add the newly received digit to the target
5 - loop back to 2 and keep going until the end of input is reached

The number is now in the int variable

Acctually i didn't understand how to turn in into an int could u show me an exemple ?

An example

#include <Keypad.h>

unsigned long targetNumber = 0;

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

byte colPins[COLS] = {2, 4, 7, 8}; //column pins  (R0 - R3)
byte rowPins[ROWS] = {10, 11, 12, A0}; //row pins  (L0 - L3)

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
  Serial.begin(115200);
  Serial.println("Enter numbers 1 to 9 on the keypad");
  Serial.println("Press # to see the whole number");
  Serial.println("or * to reset it to zero at any time");
}

void loop()
{
  char key = keypad.getKey();
  if (key)
  {
    if (key == '*')
    {
      targetNumber = 0;   //reset if * key pressed
      Serial.println("Target number has been reset to 0");
    }
    else if (key == '#')  // show final total if # key pressed
    {
      Serial.print("Final number = ");
      Serial.println(targetNumber);
      targetNumber = 0;
    }
    else if (key >= '0' && key <= '9')
    {
      Serial.println(key);
      targetNumber *= 10;
      targetNumber += key - '0';
    }
  }
}

it didn't work :confused:
the logic is wrong

yacineyaker:
it didn't work :confused:

Just about the single most annoying, most useless thing you could write.

yacineyaker:
it didn't work :confused:
the logic is wrong

Please explain what you mean.

What didn't work ?
Where is the logic wrong ?

sorry it was my fault in connection mu keypad to arduino and thank you very much