Re: converting keypad input to integer

i want to move the robotic car with keypad from point “A” to point “B”…for this i want to get three integers from the keypad…first integer is for forward motion,second integer is for turn.and third integer is for fowrad motion after turn,for rotary encoder 59pulses = 1meter…
i fix ‘0’ for turn…if i press 1,store this interger as 1 in first variable,then press ‘0’,store this integer as 0 in second variable,then i press 5,store this integer in third variable…,
problem is that i enter three integers from keypad…but my program stuck in forward motion and car moves forward without any turn
void loop() {

int u1 = 59; //59pulses = 1meter
v1 = GetNumber();
w1 = v1 * u1 ; // forward motion

int u2 = 55; // 55pulses = 90 degree turn
v2 = GetNumber();
w2 = u2 + v2 + w1; // v2 always = 0 from the keypad

v3 = GetNumber();
w3 = v3 + u1 + w2;

if ( encoderValue < w1 )
{
forward ();
}
else if (encoderValue < w2)
{
turn ();
}
else if (encoderValue < w3)
{
forward ();
}
else if (encoderValue > w3)
{
Stop ();
}
}
int GetNumber()
{
int num =0;

char key = kpd.getKey();
while(key != ‘#’)
{
switch (key)
{
case NO_KEY:
break;
case ‘0’: case ‘1’: case ‘2’: case ‘3’: case ‘4’:
case ‘5’: case ‘6’: case ‘7’: case ‘8’: case ‘9’:
// lcd.print(key);
num = key - 48 ;
//num = num * 10 + (key - ‘0’);
break;
case ‘*’:
num = 0;
// lcd.clear();
break;
}
key = kpd.getKey();
}
return num;
}

i am new to arduino..plz help me.. i want to move the car from position "A" to position "B"..and distance is given by keypad..press 1,,then 0,,then 1 means it will cover 1 meter forward motion then take turn,,after turn it will cover 1 meter forward motion.. i am taking three values from keypad but my program stuck in first condition,,it moves forward and condition didn't get fail.. :(

samiq: i am new to arduino..plz help me.. i want to move the car from position "A" to position "B"..and distance is given by keypad..press 1,,then 0,,then 1 means it will cover 1 meter forward motion then take turn,,after turn it will cover 1 meter forward motion.. i am taking three values from keypad but my program stuck in first condition,,it moves forward and condition didn't get fail.. :(

Well, it's hard to help someone who necro's a thread to double post... http://forum.arduino.cc/index.php?topic=290177.0

... and doesn't give any feedback to the suggestions that were posted there.

Use serial.print() to print the value of w1 and encoderValue.

@samiq, stop cross-posting. Stop hijacking.

@aarg, I apologize. I believe some (one?) of your posts did not make it here. I modified your post above to include the content.