entering decimals with keypad

Hello,
Just so we are clear, I have very limited knowledge of programming.
I want to make this work: https://brainy-bits.com/tutorials/diy-stepper-miter-box/

I already built it exactly as the tutorial, it work in mm, but i'd like inches.
How can i input decimal numbers with the keypad?

I tried searching, but cant get to make it work

Thank you

Richard

/* Arduino Control Stepper with Keypad and LCD
 
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
 
*/
 
#include <AccelStepper.h> // AccelStepper Library
#include <Keypad.h>  // Keypad Library
#include "U8glib.h"  // U8glib for Nokia LCD
 
// Variables to hold entered number on Keypad
volatile int firstnumber=99;  // used to tell how many numbers were entered on keypad
volatile int secondnumber=99;
volatile int thirdnumber=99;
 
// Variables to hold Distance and CurrentPosition
int keyfullnumber=0;  // used to store the final calculated distance value
String currentposition = "";  // Used for display on Nokia LCD
 
 
// Keypad Setup
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'}
};
byte rowPins[ROWS] = {22, 24, 26, 28}; // Arduino pins connected to the row pins of the keypad
byte colPins[COLS] = {31, 33, 35, 37}; // Arduino pins connected to the column pins of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );  // Keypad Library definition
 
 
// U8glib Setup for Nokia LCD
#define backlight_pin 11
U8GLIB_PCD8544 u8g(3, 4, 6, 5, 7);  // Arduino pins connected to Nokia pins:
                                    // CLK=3, DIN=4, CE=6, DC=5, RST=7
                                    
                                    
// AccelStepper Setup
AccelStepper stepper(1, A0, A1);  // 1 = Easy Driver interface
                                  // Arduino A0 connected to STEP pin of Easy Driver
                                  // Arduino A1 connected to DIR pin of Easy Driver
                                  
 
 
void setup(void) {
  
  //  Light up the LCD backlight LEDS
  analogWrite(backlight_pin, 0);  // Set the Backlight intensity (0=Bright, 255=Dim)
    
  //  AccelStepper speed and acceleration setup
  stepper.setMaxSpeed(1500);  // Not to fast or you will have missed steps
  stepper.setAcceleration(400);  //  Same here
  
  // Draw starting screen on Nokia LCD
  u8g.firstPage();
  do {
  u8g.drawHLine(0, 15, 84);
  u8g.drawVLine(50, 16, 38);
  u8g.drawHLine(0, 35, 84); 
  u8g.setFont(u8g_font_profont11);
  u8g.drawStr(0, 10, "ENTER DISTANCE");
  u8g.drawStr(62, 29, "MM");
  u8g.drawStr(4, 46, "cur-pos");
  }
  while( u8g.nextPage() );
  
}
 
 
void loop(){
  
  char keypressed = keypad.getKey();  // Get value of keypad button if pressed
  if (keypressed != NO_KEY){  // If keypad button pressed check which key it was
    switch (keypressed) {
      
      case '1':
        checknumber(1);
      break;
        
      case '2':
        checknumber(2);
      break;
 
      case '3':
        checknumber(3);
      break;
 
      case '4':
        checknumber(4);
      break;
 
      case '5':
        checknumber(5);
      break;
 
      case '6':
        checknumber(6);
      break;
 
      case '7':
        checknumber(7);
      break;
 
      case '8':
        checknumber(8);
      break;
 
      case '9':
        checknumber(9);
      break;
 
      case '0':
        checknumber(0);
      break;
 
      case '*':
        deletenumber();
      break;
 
      case '#':
        calculatedistance();
      break;
    }
  }
 
}
 
void checknumber(int x){
  if (firstnumber == 99) { // Check if this is the first number entered
    firstnumber=x;
    String displayvalue = String(firstnumber);  //  Transform int to a string for display
    drawnokiascreen(displayvalue); // Redraw Nokia lcd
    
  } else {
    if (secondnumber == 99) {  // Check if it's the second number entered
      secondnumber=x;
      String displayvalue = (String(firstnumber) + String(secondnumber));
      drawnokiascreen(displayvalue);
 
    } else {  // It must be the 3rd number entered
      thirdnumber=x;
      String displayvalue = (String(firstnumber) + String(secondnumber) + String(thirdnumber));
      drawnokiascreen(displayvalue);
 
    }
  }
}
 
 
void deletenumber() {  // Used to backspace entered numbers
  if (thirdnumber !=99) {
      String displayvalue = (String(firstnumber) + String(secondnumber));
      drawnokiascreen(displayvalue);
 
    thirdnumber=99;
  } 
  else {
    if (secondnumber !=99) {
      String displayvalue = String(firstnumber);
      drawnokiascreen(displayvalue);
 
      secondnumber=99;
   } 
   else {
     if (firstnumber !=99) {
       String displayvalue = "";
       drawnokiascreen(displayvalue);
 
       firstnumber=99;
      }
    }
  }
}
  
void calculatedistance() {  // Used to create a full number from entered numbers
 
    if (thirdnumber == 99 && secondnumber == 99 && firstnumber != 99) {
      keyfullnumber=firstnumber;
      movestepper(keyfullnumber);
    }
    
    if (secondnumber != 99 && thirdnumber == 99) {
      keyfullnumber=(firstnumber*10)+secondnumber;
      movestepper(keyfullnumber);
    }
    
    if (thirdnumber != 99) {
      keyfullnumber=(firstnumber*100)+(secondnumber*10)+thirdnumber;
      movestepper(keyfullnumber);
    }
    
    resetnumbers(); // Reset numbers to get ready for new entry
  } 
 
 
void movestepper(int z) {  //  Move the stepper
 
  int calculatedmove=((z*1600)/80);  //  Calculate number of steps needed in mm
  stepper.runToNewPosition(calculatedmove);
  currentposition = String(z);
  u8g.firstPage();
  do {
    u8g.drawHLine(0, 15, 84);
    u8g.drawVLine(50, 16, 38);
    u8g.drawHLine(0, 35, 84); 
    u8g.setFont(u8g_font_profont11);
    u8g.drawStr(0, 10, "ENTER DISTANCE");
    u8g.drawStr(62, 29, "MM");
    u8g.drawStr(4, 46, "cur-pos");
    u8g.setPrintPos(57,47);
    u8g.print(currentposition);       
  }
  while( u8g.nextPage() ); 
}
                
void resetnumbers() {  // Reset numbers for next entry
  firstnumber=99;
  secondnumber=99;
  thirdnumber=99;
} 
  
 
void drawnokiascreen(String y) {
 
    u8g.firstPage();
    do {
      u8g.drawHLine(0, 15, 84);
      u8g.drawVLine(50, 16, 38);
      u8g.drawHLine(0, 35, 84); 
      u8g.setFont(u8g_font_profont11);
      u8g.drawStr(0, 10, "ENTER DISTANCE");
      u8g.setPrintPos(0,29);
      u8g.print(y);  // Put entered number on Nokia lcd    
      u8g.drawStr(62, 29, "MM");
      u8g.drawStr(4, 46, "cur-pos");
      u8g.setPrintPos(57,47); 
      u8g.print(currentposition);  //  Display current position of stepper
    }
      while( u8g.nextPage() );
 
}
    switch (keypressed) {
     
      case '1':
        checknumber(1);
      break;
       
      case '2':
        checknumber(2);

Do you see a pattern here? Do you have any idea what '2' - '0' equals?

That code is crap. You need some kind of "done entering digits; use the number" key. Which key will that be?

You need some kind of decimal point key. Which key is that going to be?

You need some kind of "oops. Ignore all data entered so far" key. Which key is that going to be?

You need to store the key characters in an array, followed by a NULL, substituting a decimal point for the decimal point key, until the "done entering digits; use the number" key is pressed. When that happens, use atof() to convert the string to a float.

done entering numbers key: #
decimal point key: D
ignore data entered so far key: *

i get what you are saying for the decimal point and float value,
but i guess it is a little out of my league.
I get what a code does by looking at it, and i can modify to a point, but have a hard time programming from scratch

Thanks

but have a hard time programming from scratch

All beginners do.

That is why we recommend starting with the basic Arduino examples, to learn the special features of the Arduino, and to study different styles of coding. Also study on-line C/C++ language tutorials.

I get what a code does by looking at it, and i can modify to a point, but have a hard time programming from scratch

// Global variables
byte index = 0;
char numbers[20]; // Plenty to store a representation of a float

In loop(), get rid of the switch statement and all the code in the cases. The function should look like:

void loop()
{
   char key = keypad.getKey();
   if(key != NO_KEY)
   {
      if(key == '*')
      {
         index = 0;
         numbers[index] = '\0';
      }
      else if(key == 'D')
      {
         numbers[index++] = '.';
         numbers[index] = '\0';
      }
      else if(key >= '0' && key <= '9')
      {
         numbers[index++] = key;
         numbers[index] = '\0';
      }
      else if(key == '#')
      {
         float len = atof(numbers);
         // Do whatever you need to with len

         index = 0;
         numbers[index] = '\0';
      }
   }
}

Of course, the movestepper() function will need to be re-written to accept a float, and convert that distance in inches to steps.

like this?

i might have a problem with the variables definition at the top, because i get an error message when i get arduino to verify

/* Arduino Control Stepper with Keypad and LCD
 
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
 
*/
 
#include <AccelStepper.h> // AccelStepper Library
#include <Keypad.h>  // Keypad Library
#include "U8glib.h"  // U8glib for Nokia LCD
 
// Variables to hold entered number on Keypad
float len = 0;
int y = 0;
// Variables to hold Distance and CurrentPosition

String currentposition = "";  // Used for display on Nokia LCD
 
 
// Keypad Setup
const byte ROWS = 5; // Five Rows
const byte COLS = 4; // Four Columns
char keys[ROWS][COLS] = {
  {'F','G','#','*'},
  {'1','2','3','U'},
  {'4','5','6','D'},
  {'7','8','9','E'},
  {'L','0','R','N'}
};
byte rowPins[ROWS] = {22, 24, 26, 28, 30}; // Arduino pins connected to the row pins of the keypad
byte colPins[COLS] = {31, 33, 35, 37}; // Arduino pins connected to the column pins of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );  // Keypad Library definition
 
 
// U8glib Setup for Nokia LCD
#define backlight_pin 11
U8GLIB_PCD8544 u8g(3, 4, 6, 5, 7);  // Arduino pins connected to Nokia pins:
                                    // CLK=3, DIN=4, CE=6, DC=5, RST=7
                                    
                                    
// AccelStepper Setup
AccelStepper stepper(1, A0, A1);  // 1 = Easy Driver interface
                                  // Arduino A0 connected to STEP pin of Easy Driver
                                  // Arduino A1 connected to DIR pin of Easy Driver
                                  
 
 
void setup(void) {
  
  //  Light up the LCD backlight LEDS
  analogWrite(backlight_pin, 0);  // Set the Backlight intensity (0=Bright, 255=Dim)
    
  //  AccelStepper speed and acceleration setup
  stepper.setMaxSpeed(1500);  // Not to fast or you will have missed steps
  stepper.setAcceleration(400);  //  Same here
  
  // Draw starting screen on Nokia LCD
  u8g.firstPage();
  do {
  u8g.drawHLine(0, 15, 84);
  u8g.drawVLine(50, 16, 38);
  u8g.drawHLine(0, 35, 84); 
  u8g.setFont(u8g_font_profont11);
  u8g.drawStr(0, 10, "ENTER DISTANCE");
  u8g.drawStr(62, 29, "in");
  u8g.drawStr(4, 46, "cur-pos");
  }
  while( u8g.nextPage() );
  
}
 
 

  
void loop()
{
   char key = keypad.getKey();
   if(key != NO_KEY)
   {
      if(key == '*')
      {
         index = 0;
         numbers[index] = '\0';
      }
      else if(key == 'D')
      {
         numbers[index++] = '.';
         numbers[index] = '\0';
      }
      else if(key >= '0' && key <= '9')
      {
         numbers[index++] = key;
         numbers[index] = '\0';
      }
      else if(key == '#')
      {
         float len = atof(numbers);
         drawnokiascreen(len);
         movestepper(len);
         // Do whatever you need to with len
       
         index = 0;
         numbers[index] = '\0';
      }
   }
}           
 
 
void movestepper(int z) {  //  Move the stepper
 
  int calculatedmove=((z*1600)/80);  //  Calculate number of steps needed in mm
  stepper.runToNewPosition(calculatedmove);
  currentposition = String(z);
  u8g.firstPage();
  do {
    u8g.drawHLine(0, 15, 84);
    u8g.drawVLine(50, 16, 38);
    u8g.drawHLine(0, 35, 84); 
    u8g.setFont(u8g_font_profont11);
    u8g.drawStr(0, 10, "ENTER DISTANCE");
    u8g.drawStr(62, 29, "MM");
    u8g.drawStr(4, 46, "cur-pos");
    u8g.setPrintPos(57,47);
    u8g.print(currentposition);       
  }
  while( u8g.nextPage() ); 
}
                

 
void drawnokiascreen(String y) {
 
    u8g.firstPage();
    do {
      u8g.drawHLine(0, 15, 84);
      u8g.drawVLine(50, 16, 38);
      u8g.drawHLine(0, 35, 84); 
      u8g.setFont(u8g_font_profont11);
      u8g.drawStr(0, 10, "ENTER DISTANCE");
      u8g.setPrintPos(0,29);
      u8g.print(y);  // Put entered number on Nokia lcd    
      u8g.drawStr(62, 29, "MM");
      u8g.drawStr(4, 46, "cur-pos");
      u8g.setPrintPos(57,47); 
      u8g.print(currentposition);  //  Display current position of stepper
    }
      while( u8g.nextPage() );
 
}

i might have a problem with the variables definition at the top, because i get an error message when i get arduino to verify

I showed two blocks of code. You used one of them.

You need to change movestepper() to accept a float, not an int.

Sorry, i went right over the first block of code.

i am having a hard time getting the movestepper() to work
hers where i am at;

/* Arduino Control Stepper with Keypad and LCD
 
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
 
*/
 
#include <AccelStepper.h> // AccelStepper Library
#include <Keypad.h>  // Keypad Library
#include "U8glib.h"  // U8glib for Nokia LCD
 

// Global variables
float x=0
byte index = 0;
char numbers[20]; // Plenty to store a representation of a float
// Variables to hold Distance and CurrentPosition

String currentposition = "";  // Used for display on Nokia LCD
 
 
// Keypad Setup
const byte ROWS = 5; // Five Rows
const byte COLS = 4; // Four Columns
char keys[ROWS][COLS] = {
  {'F','G','#','*'},
  {'1','2','3','U'},
  {'4','5','6','D'},
  {'7','8','9','E'},
  {'L','0','R','N'}
};
byte rowPins[ROWS] = {22, 24, 26, 28, 30}; // Arduino pins connected to the row pins of the keypad
byte colPins[COLS] = {31, 33, 35, 37}; // Arduino pins connected to the column pins of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );  // Keypad Library definition
 
 
// U8glib Setup for Nokia LCD
#define backlight_pin 11
U8GLIB_PCD8544 u8g(3, 4, 6, 5, 7);  // Arduino pins connected to Nokia pins:
                                    // CLK=3, DIN=4, CE=6, DC=5, RST=7
                                    
                                    
// AccelStepper Setup
AccelStepper stepper(1, A0, A1);  // 1 = Easy Driver interface
                                  // Arduino A0 connected to STEP pin of Easy Driver
                                  // Arduino A1 connected to DIR pin of Easy Driver
                                  
 
 
void setup(void) {
  
  //  Light up the LCD backlight LEDS
  analogWrite(backlight_pin, 0);  // Set the Backlight intensity (0=Bright, 255=Dim)
    
  //  AccelStepper speed and acceleration setup
  stepper.setMaxSpeed(1500);  // Not to fast or you will have missed steps
  stepper.setAcceleration(400);  //  Same here
  
  // Draw starting screen on Nokia LCD
  u8g.firstPage();
  do {
  u8g.drawHLine(0, 15, 84);
  u8g.drawVLine(50, 16, 38);
  u8g.drawHLine(0, 35, 84); 
  u8g.setFont(u8g_font_profont11);
  u8g.drawStr(0, 10, "ENTER DISTANCE");
  u8g.drawStr(62, 29, "in");
  u8g.drawStr(4, 46, "cur-pos");
  }
  while( u8g.nextPage() );
  
}
 
 

  
void loop()
{
   char key = keypad.getKey();
   if(key != NO_KEY)
   {
      if(key == '*')
      {
         index = 0;
         numbers[index] = '\0';
      }
      else if(key == 'D')
      {
         numbers[index++] = '.';
         numbers[index] = '\0';
      }
      else if(key >= '0' && key <= '9')
      {
         numbers[index++] = key;
         numbers[index] = '\0';
      }
      else if(key == '#')
      {
         float x = atof(numbers);
         drawnokiascreen();
         movestepper();
         // Do whatever you need to with len
       
         index = 0;
         numbers[index] = '\0';
      }
   }
}           
 
 
void movestepper() {  //  Move the stepper

  
   calculatedmove=(x*1600);  //  Calculate number of steps needed in mm
  stepper.runToNewPosition(calculatedmove);
  currentposition = String(z);
  u8g.firstPage();
  do {
    u8g.drawHLine(0, 15, 84);
    u8g.drawVLine(50, 16, 38);
    u8g.drawHLine(0, 35, 84); 
    u8g.setFont(u8g_font_profont11);
    u8g.drawStr(0, 10, "ENTER DISTANCE");
    u8g.drawStr(62, 29, "in");
    u8g.drawStr(4, 46, "cur-pos");
    u8g.setPrintPos(57,47);
    u8g.print(currentposition);       
  }
  while( u8g.nextPage() ); 
}
                

 
void drawnokiascreen(String y) {
 
    u8g.firstPage();
    do {
      u8g.drawHLine(0, 15, 84);
      u8g.drawVLine(50, 16, 38);
      u8g.drawHLine(0, 35, 84); 
      u8g.setFont(u8g_font_profont11);
      u8g.drawStr(0, 10, "ENTER DISTANCE");
      u8g.setPrintPos(0,29);
      u8g.print(y);  // Put entered number on Nokia lcd    
      u8g.drawStr(62, 29, "in");
      u8g.drawStr(4, 46, "cur-pos");
      u8g.setPrintPos(57,47); 
      u8g.print(currentposition);  //  Display current position of stepper
    }
      while( u8g.nextPage() );
 
}

You have a global variable named x (with no ; after it) and a local variable named x. Which one is the movestepper() function going to see? Which one has a value? Rather, which one has an interesting value?

Why does movestepper() diddle with the u8g instance?

In my part of the world, there are not 80 mm per inch. I don't know about yours. Actually I do. There are not 80 mm per inch there, either.

I dont know about the variable x, i was trying to get the float value into the movestepper() function.

As for the 80mm, its from the original code, i havent changed it, it ran in mm, and used a timing pulley, hence the funny ratio.

Change your movestepper so it takes an argument

/*
  move the stepper
  in:
    distance to move
*/
void movestepper(float distance)
{
  calculatedmove = (distance * 1600);
  ...
  ...
}

And in loop, pass the distance to the movestepper function

    else if (key == '#')
    {
      float x = atof(numbers);
      drawnokiascreen();
      movestepper(x);
      // Do whatever you need to with len

      index = 0;
      numbers[index] = '\0';
    }

like that?
i thought the u8g was to rewrite the nokia screen to show the new position?
or do i just need to have the drawnokiascreen(); command and have variables in the
void drawnokiascreen(); ?

/* Arduino Control Stepper with Keypad and LCD
 
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
 
*/
 
#include <AccelStepper.h> // AccelStepper Library
#include <Keypad.h>  // Keypad Library
#include "U8glib.h"  // U8glib for Nokia LCD
 

// Global variables
float x=0
byte index = 0;
char numbers[20]; // Plenty to store a representation of a float
// Variables to hold Distance and CurrentPosition

String currentposition = "";  // Used for display on Nokia LCD
 
 
// Keypad Setup
const byte ROWS = 5; // Five Rows
const byte COLS = 4; // Four Columns
char keys[ROWS][COLS] = {
  {'F','G','#','*'},
  {'1','2','3','U'},
  {'4','5','6','D'},
  {'7','8','9','E'},
  {'L','0','R','N'}
};
byte rowPins[ROWS] = {22, 24, 26, 28, 30}; // Arduino pins connected to the row pins of the keypad
byte colPins[COLS] = {31, 33, 35, 37}; // Arduino pins connected to the column pins of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );  // Keypad Library definition
 
 
// U8glib Setup for Nokia LCD
#define backlight_pin 11
U8GLIB_PCD8544 u8g(3, 4, 6, 5, 7);  // Arduino pins connected to Nokia pins:
                                    // CLK=3, DIN=4, CE=6, DC=5, RST=7
                                    
                                    
// AccelStepper Setup
AccelStepper stepper(1, A0, A1);  // 1 = Easy Driver interface
                                  // Arduino A0 connected to STEP pin of Easy Driver
                                  // Arduino A1 connected to DIR pin of Easy Driver
                                  
 
 
void setup(void) {
  
  //  Light up the LCD backlight LEDS
  analogWrite(backlight_pin, 0);  // Set the Backlight intensity (0=Bright, 255=Dim)
    
  //  AccelStepper speed and acceleration setup
  stepper.setMaxSpeed(1500);  // Not to fast or you will have missed steps
  stepper.setAcceleration(400);  //  Same here
  
  // Draw starting screen on Nokia LCD
  u8g.firstPage();
  do {
  u8g.drawHLine(0, 15, 84);
  u8g.drawVLine(50, 16, 38);
  u8g.drawHLine(0, 35, 84); 
  u8g.setFont(u8g_font_profont11);
  u8g.drawStr(0, 10, "ENTER DISTANCE");
  u8g.drawStr(62, 29, "in");
  u8g.drawStr(4, 46, "cur-pos");
  }
  while( u8g.nextPage() );
  
}
 
 

  
void loop()
{
   char key = keypad.getKey();
   if(key != NO_KEY)
   {
      if(key == '*')
      {
         index = 0;
         numbers[index] = '\0';
      }
      else if(key == 'D')
      {
         numbers[index++] = '.';
         numbers[index] = '\0';
      }
      else if(key >= '0' && key <= '9')
      {
         numbers[index++] = key;
         numbers[index] = '\0';
      }
      else if(key == '#')
      {
         float x = atof(numbers);
         drawnokiascreen();
         movestepper(x);
         // Do whatever you need to with len
       
         index = 0;
         numbers[index] = '\0';
      }
   }
}           
 
 


  void movestepper(float distance)
{
 
    calculatedmove = (distance * 1600); //  Calculate number of steps needed in mm
  stepper.runToNewPosition(calculatedmove);
  currentposition = String(distance);
  u8g.firstPage();
  do {
    u8g.drawHLine(0, 15, 84);
    u8g.drawVLine(50, 16, 38);
    u8g.drawHLine(0, 35, 84); 
    u8g.setFont(u8g_font_profont11);
    u8g.drawStr(0, 10, "ENTER DISTANCE");
    u8g.drawStr(62, 29, "in");
    u8g.drawStr(4, 46, "cur-pos");
    u8g.setPrintPos(57,47);
    u8g.print(currentposition);       
  }
  while( u8g.nextPage() ); 
}
                

 
void drawnokiascreen(String y) {
 
    u8g.firstPage();
    do {
      u8g.drawHLine(0, 15, 84);
      u8g.drawVLine(50, 16, 38);
      u8g.drawHLine(0, 35, 84); 
      u8g.setFont(u8g_font_profont11);
      u8g.drawStr(0, 10, "ENTER DISTANCE");
      u8g.setPrintPos(0,29);
      u8g.print(y);  // Put entered number on Nokia lcd    
      u8g.drawStr(62, 29, "in");
      u8g.drawStr(4, 46, "cur-pos");
      u8g.setPrintPos(57,47); 
      u8g.print(currentposition);  //  Display current position of stepper
    }
      while( u8g.nextPage() );
 
}

i thought the u8g was to rewrite the nokia screen to show the new position?

It is.

or do i just need to have the drawnokiascreen(); command and have variables in the
void drawnokiascreen(); ?

You need to pass an argument (the value to print) to the function.

// Global variables
float x=0

Why do you keep posting code that won't even compile?

GET RID OF THAT GLOBAL VARIABLE!

void movestepper(int z) {  //  Move the stepper
 
  int calculatedmove=((z*1600)/80);  //  Calculate number of steps needed in mm
  void movestepper(float distance)
{
 
    calculatedmove = (distance * 1600); //  Calculate number of steps needed in mm

If the argument was a distance in mm, the argument name should have reflected that.

If the argument is a distance in inches, the argument name should reflect that.

If the number of steps per mm is 20 (1600/80), the number of steps per inch is NOT 1600. It is 508.

i changed the steps so the stepper turns 1 turn for every inch.
changed the nokia screen command to always go to drawnokiascreen(); with variables distance for entered numbers on keypad, and currentposition for the current position of the stepper.

/* Arduino Control Stepper with Keypad and LCD
 
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
 
*/
 
#include <AccelStepper.h> // AccelStepper Library
#include <Keypad.h>  // Keypad Library
#include "U8glib.h"  // U8glib for Nokia LCD
 

// Global variables

byte index = 0;
char numbers[20]; // Plenty to store a representation of a float
// Variables to hold Distance and CurrentPosition

String currentposition = "";  // Used for display on Nokia LCD
 
 
// Keypad Setup
const byte ROWS = 5; // Five Rows
const byte COLS = 4; // Four Columns
char keys[ROWS][COLS] = {
  {'F','G','#','*'},
  {'1','2','3','U'},
  {'4','5','6','D'},
  {'7','8','9','E'},
  {'L','0','R','N'}
};
byte rowPins[ROWS] = {22, 24, 26, 28, 30}; // Arduino pins connected to the row pins of the keypad
byte colPins[COLS] = {31, 33, 35, 37}; // Arduino pins connected to the column pins of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );  // Keypad Library definition
 
 
// U8glib Setup for Nokia LCD
#define backlight_pin 11
U8GLIB_PCD8544 u8g(3, 4, 6, 5, 7);  // Arduino pins connected to Nokia pins:
                                    // CLK=3, DIN=4, CE=6, DC=5, RST=7
                                    
                                    
// AccelStepper Setup
AccelStepper stepper(1, A0, A1);  // 1 = Easy Driver interface
                                  // Arduino A0 connected to STEP pin of Easy Driver
                                  // Arduino A1 connected to DIR pin of Easy Driver
                                  
 
 
void setup(void) {
  
  //  Light up the LCD backlight LEDS
  analogWrite(backlight_pin, 0);  // Set the Backlight intensity (0=Bright, 255=Dim)
    
  //  AccelStepper speed and acceleration setup
  stepper.setMaxSpeed(1500);  // Not to fast or you will have missed steps
  stepper.setAcceleration(400);  //  Same here
  
  // Draw starting screen on Nokia LCD
  u8g.firstPage();
  do {
  u8g.drawHLine(0, 15, 84);
  u8g.drawVLine(50, 16, 38);
  u8g.drawHLine(0, 35, 84); 
  u8g.setFont(u8g_font_profont11);
  u8g.drawStr(0, 10, "ENTER DISTANCE");
  u8g.drawStr(62, 29, "in");
  u8g.drawStr(4, 46, "cur-pos");
  }
  while( u8g.nextPage() );
  
}
 
 

  
void loop()
{
   char key = keypad.getKey();
   if(key != NO_KEY)
   {
      if(key == '*')
      {
         index = 0;
         numbers[index] = '\0';
      }
      else if(key == 'D')
      {
         numbers[index++] = '.';
         numbers[index] = '\0';
      }
      else if(key >= '0' && key <= '9')
      {
         numbers[index++] = key;
         numbers[index] = '\0';
      }
      else if(key == '#')
      {
         float x = atof(numbers);
         drawnokiascreen();
         movestepper(x);
         // Do whatever you need to with len
       
         index = 0;
         numbers[index] = '\0';
      }
   }
}           
 
 


  void movestepper(float distance)
{
 
    calculatedmove = (distance * 1600); //  1 inch equals 1 turn with microstepping
  stepper.runToNewPosition(calculatedmove);
  currentposition = String(distance);
  distance= 0 // resets distance entered to be ready for next entry
  drawnokiascreen();
}
                

 
void drawnokiascreen(String y) {
 
    u8g.firstPage();
    do {
      u8g.drawHLine(0, 15, 84);
      u8g.drawVLine(50, 16, 38);
      u8g.drawHLine(0, 35, 84); 
      u8g.setFont(u8g_font_profont11);
      u8g.drawStr(0, 10, "ENTER DISTANCE");
      u8g.setPrintPos(0,29);
      u8g.print(distance);  // Put entered number on Nokia lcd    
      u8g.drawStr(62, 29, "in");
      u8g.drawStr(4, 46, "cur-pos");
      u8g.setPrintPos(57,47); 
      u8g.print(currentposition);  //  Display current position of stepper
    }
      while( u8g.nextPage() );
 
}

You have a function, drawnokiascreen(), defined, which takes one argument.

You call that function:

      else if(key == '#')
      {
         float x = atof(numbers);
         drawnokiascreen();

I'm sure that the compiler didn't care much for that.

So, I'll ask again. Why are you posting code that can't even compile?

Ok, now this works in the program, and I've been able to enter a few distances to run.

But now, I upload the code, enter 1 dimension (ex: 8.5)
it displays the dimension: 8.500
then it freezes, i cant input anything else.

/* Arduino Control Stepper with Keypad and LCD
 
Created by Yvan / https://Brainy-Bits.com
This code is in the public domain...
You can: copy it, use it, modify it, share it or just plain ignore it!
Thx!
 
*/
 
#include <AccelStepper.h> // AccelStepper Library
#include <Keypad.h>  // Keypad Library
#include "U8glib.h"  // U8glib for Nokia LCD
 

// Global variables
byte index = 0;
char numbers[20]; // Plenty to store a representation of a float
// Variable to hold CurrentPosition

String currentposition = "";  // Used for display on Nokia LCD
 
 
// Keypad Setup
const byte ROWS = 5; // Five Rows
const byte COLS = 4; // Four Columns
char keys[ROWS][COLS] = {
  {'F','G','#','*'},
  {'1','2','3','U'},
  {'4','5','6','D'},
  {'7','8','9','E'},
  {'L','0','R','N'}
};
byte rowPins[ROWS] = {22, 24, 26, 28, 30}; // Arduino pins connected to the row pins of the keypad
byte colPins[COLS] = {31, 33, 35, 37}; // Arduino pins connected to the column pins of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );  // Keypad Library definition
 
 
// U8glib Setup for Nokia LCD
#define backlight_pin 11
U8GLIB_PCD8544 u8g(3, 4, 6, 5, 7);  // Arduino pins connected to Nokia pins:
                                    // CLK=3, DIN=4, CE=6, DC=5, RST=7
                                    
                                    
// AccelStepper Setup
AccelStepper stepper(1, A2, A3);  // 1 = Easy Driver interface
                                  // Arduino A2 connected to STEP pin of Easy Driver
                                  // Arduino A3 connected to DIR pin of Easy Driver
                                  
 static char outstr[15];
 
void setup(void) {

  float len=000.000;
   
  
  
  //  Light up the LCD backlight LEDS
  analogWrite(backlight_pin, 0);  // Set the Backlight intensity (0=Bright, 255=Dim)
    
  //  AccelStepper speed and acceleration setup
  stepper.setMaxSpeed(1500);  // Not to fast or you will have missed steps
  stepper.setAcceleration(400);  //  Same here
  
  // Draw starting screen on Nokia LCD
  u8g.firstPage();
  do {
  u8g.drawHLine(0, 15, 84);
  u8g.drawVLine(50, 16, 20);
  u8g.drawHLine(0, 35, 84); 
  u8g.setFont(u8g_font_profont11);
  u8g.drawStr(0, 10, "ENTER DISTANCE");
  u8g.drawStr(62, 29, "in");
  
  }
  while( u8g.nextPage() );
  
}
 

void loop()
{
   char key = keypad.getKey();
   if(key != NO_KEY)
   {
      if(key == 'E')
      {
         index = 0;
         numbers[index] = '\0';
      }
      else if(key == '*')
      {
         numbers[index++] = '.';
         numbers[index] = '\0';
      }
      else if(key >= '0' && key <= '9')
      {
         numbers[index++] = key;
         numbers[index] = '\0';
      }
      else if(key == 'N')
      {
         float len = atof(numbers);  // Do whatever you need to with len
        
         dtostrf(len,7, 3, outstr);
         drawnokiascreen(outstr);
         

  stepper.runToNewPosition(len*1600); //  1600 steps for 1 inch 
     
  
         index = 0;
         numbers[index] = '\0';
        
      }
   }
}           
 
 


 
 
void drawnokiascreen(String outstr) {
 
    u8g.firstPage();
    do {
      u8g.drawHLine(0, 15, 84);
      u8g.drawVLine(50, 16, 20);
      u8g.drawHLine(0, 35, 84); 
      u8g.setFont(u8g_font_profont11);
      u8g.drawStr(0, 10, "ENTER DISTANCE");
      u8g.drawStr(62, 29, "in");
      u8g.setPrintPos(4,46); 
      u8g.print(outstr);  //  Display current position of stepper
    }
      while( u8g.nextPage() );
 
}

My bad, once the stepper motor was on, everything worked!

Anybody know how to get the current stepper position?
I'm trying to save it into eeprom, then load it on startup
not to lose position when turned off.

also, while typing the numbers, they dont appear on the screen, I'm having trouble implementing that.

I'm having trouble implementing that.

That's a shame.

Got it (displaying the keypad inputs that is)