Motor will not run on macro slide

I'll start with what I'm trying to do & then where I'm up to & my current issue.

I'm trying to do the following...

  1. Start on button push (implemented in code)
  2. Set the interval between camera shots (not finished)
  3. Set the number of frames to be taken (not implemented in code yet)
  4. Set the number of stepper steps before camera is triggered (implemented in code)
  5. Reset to start.

What I have achieved so far...

  1. Stepper attached to slide.
  2. Arduino control of stepper (using other code)
  3. LCD menu working using phi_prompt library

What my current issue is...
When I start I get no motor movement, the LCD shows "1" as it should & that is it nothing else.

Would someone be so kind as to have a look at my code & help me work through this current issue & move forward from here.

My code is split into two tabs, "My_Menu_2_1" & "menu"

Tab one ( My_Menu_2_1 )

  /*
  
  It Works...
  This sketch will compile & upload giving menus that do nothing.
  Next, make the menus do somthing...
  
  */

  #include <LiquidCrystal.h>
  #include <Wire.h>
  #include <stdio.h>
  #include <avr/pgmspace.h>
  #include <phi_interfaces.h>
  #include <phi_prompt.h>
  #include <AFMotor.h>
  #include <AccelStepper.h>



  //Freetronics 16x2 LCD shield pin setting
  #define LCD_RS 8
  #define LCD_EN 9
  #define LCD_D4 4
  #define LCD_D5 5
  #define LCD_D6 6
  #define LCD_D7 7

  //Freetronics 16x2 LCD shield buttons and channel pin assignments
  #define lcd_rows 2
  #define lcd_columns 16

  #define analog_buttons_per_column 5 // Each analog pin has five buttons with resistors.
  #define analog_buttons_per_row 1 // There are two analog pins in use.

  #define name_length 5 // This is the max length of names.

  int user_input1=1000;  // This is the storage for the Frame Inrerval integer
  int user_input2=10;  // This is the storage for the # of Frames integer
  int user_input3=175; // This is the storage for the Motor Steps integer, 175 steps per mm
  int choice=0;      // This is the storage for the Start control.
  int shots=0;      // This is the storage for the number of shots.
      
  char analog_mapping[]={'R','U','D','L','B'}; // This is an analog keypad.
  byte analog_pins[]={0}; // The pin numbers are analog pin numbers.
  int values[]={0, 143, 328, 504, 740}; //mY Freetronics 16x2 LCD shield button values.
  phi_analog_keypads analog_keypad(analog_mapping, analog_pins, values, analog_buttons_per_row, analog_buttons_per_column);

    
  AF_Stepper motor2(200, 2);  // This sets up the Stepper motor, motor two with 200 turns per rev    


// This serial keypad is for debugging.
phi_serial_keypads debug_keypad(&Serial,115200);

  // The following sets up function keys for phi_prompt library
  char up_keys[]={"U"}; ///< All keys that act as the up key are listed here.
  char down_keys[]={"D"}; ///< All keys that act as the down key are listed here.
  char left_keys[]={"L"}; ///< All keys that act as the left key are listed here.
  char right_keys[]={"R"}; ///< All keys that act as the right key are listed here.
  char enter_keys[]={"B"}; ///< All keys that act as the enter key are listed here.
  char escape_keys[]={"A"}; ///< All keys that act as the escape key are listed here.
  char * function_keys[]={up_keys,down_keys,left_keys,right_keys,enter_keys,escape_keys}; ///< All function key names are gathered here fhr phi_prompt.
  
  // The following adds all available keypads as inputs for phi_prompt library
  multiple_button_input * keypads[]={&analog_keypad, &debug_keypad,0};
  
  // The following sets up LCD and other objects
  LiquidCrystal lcd(LCD_RS,LCD_EN,LCD_D4,LCD_D5,LCD_D6,LCD_D7); // Create the lcd object
  
  
  
  void setup()
  {
    lcd.begin(lcd_columns, lcd_rows);
    init_phi_prompt(&lcd,keypads,function_keys, lcd_columns, lcd_rows, '~'); // Supply the liquid crystal object, input keypads, and function key names. Also supply the column and row of the lcd, and indicator as '>'. You can also use '\x7e', which is a right arrow.
    Serial.begin(115200); // Serial is used as a debug keypad. This can be deleted after debug.
   
    
  }
  
  void loop() {
    top_menu(); // See menu.pde for the Macro Slide Menu
   }

Too big...

See next post...

Part two...

still too big...

Tab two (menu)

// Menu texts
PROGMEM prog_char top_menu_item00[]="Start";                 // Start the sequence of frames
PROGMEM prog_char top_menu_item01[]="Frame Interval";       // The interval between frames
PROGMEM prog_char top_menu_item02[]="# of Frames";         // The number of frames to be taken
PROGMEM prog_char top_menu_item03[]="Steps per Frame";    // The number of motor steps per frame
PROGMEM const char *top_menu_items[] = {top_menu_item00, top_menu_item01, top_menu_item02, top_menu_item03,};

//This program is the main menu. It handles inputs from the keys, updates the menu or executes a certain menu function accordingly.
int global_style=1; // This is the style of the menu
void top_menu()
{
  int menu_pointer_1=0; // This stores the menu choice the user made.
  phi_prompt_struct myMenu; // This structure stores the main menu.

// Initialize the top menu
  myMenu.ptr.list=(char**)&top_menu_items; // Assign the list to the pointer
  myMenu.low.i=0; // Default item highlighted on the list
  myMenu.high.i=4; // Last item of the list is size of the list - 1.
  myMenu.width=lcd_columns-((global_style&phi_prompt_arrow_dot)!=0)-((global_style&phi_prompt_scroll_bar)!=0); // Auto fit the size of the list to the screen. Length in characters of the longest list item.
  myMenu.step.c_arr[0]=lcd_rows-1; // rows to auto fit entire screen
  myMenu.step.c_arr[1]=1; // one col list
  myMenu.step.c_arr[2]=0; // y for additional feature such as an index
  myMenu.step.c_arr[3]=lcd_columns-4-((global_style&phi_prompt_index_list)!=0); // x for additional feature such as an index
  myMenu.col=0; // Display menu at column 0
  myMenu.row=1; // Display menu at row 1
  myMenu.option=global_style; // Option 0, display classic list, option 1, display 2X2 list, option 2, display list with index, option 3, display list with index2.
  
  while(1) // This loops every time a menu item is selected.
  {
    lcd.clear();  // Refresh menu if a button has been pushed
    center_text(" Macro Slide  ");

    myMenu.option=global_style; // This makes sure the change of menu style is updated if there is a menu style option in this level of menu.
    myMenu.width=lcd_columns-((global_style&phi_prompt_arrow_dot)!=0)-((global_style&phi_prompt_scroll_bar)!=0); // This makes sure the change of menu style is updated if there is a menu style option in this level of menu. Auto fit the size of the list to the screen. Length in characters of the longest list item.
    myMenu.step.c_arr[3]=lcd_columns-4-((global_style&phi_prompt_index_list)!=0); // This makes sure the change of menu style is updated if there is a menu style option in this level of menu. x for additional feature such as an index
    select_list(&myMenu); // Use the select_list to ask the user to select an item of the list, that is a menu item from your menu.
    menu_pointer_1=myMenu.low.i; // Get the selected item number and store it in the menu pointer.
    switch (menu_pointer_1) // See which menu item is selected and execute that correspond function
    {
      case 0:
      top_menu_function_1();
      break;
      case 1:
      top_menu_function_2();
      break;
      
      case 2:
      top_menu_function_3();
      break;
      
      case 3:
      top_menu_function_4();
      break;
  
      default:
      break;
    }

  }
}

// Menu functions go here. The functions are called when their menu items are selected. They are called only once so if you want to do something repeatedly, make sure you have a while loop.

void top_menu_function_1() //Replace this with the actual function of menu item #1
{
    int choice=yn_dialog("Start");
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print(choice);
    
        if (choice == 1); {
          motor2.setSpeed(100);  
          motor2.step(user_input3, BACKWARD, SINGLE);  //Move the motor by the number of "Steps per frame. user_input3
          }
          motor2.release();  //  make sure the motor is at rest.
          choice=0;           // reset the user choice for restart
          
    wait_on_escape(4000);
}

void top_menu_function_2() //Replace this with the actual function of menu item #2
{

    phi_prompt_struct myIntegerInput;
  
    myIntegerInput.ptr.i_buffer=&user_input1; // Pass the address of the buffer. After library function call, user input will be stored in this variable.
    myIntegerInput.low.i=0; // Lower limit of the number is 0
    myIntegerInput.high.i=20000; // Upper limit of the number is 20
    myIntegerInput.step.i=100; // Step size. User choice increments 2 every time you push up and decrements 2 when you press down.
    myIntegerInput.col=7; // Display number at column 7
    myIntegerInput.row=1; // Display number at row 1
    myIntegerInput.width=2; // The number occupies 2 characters space.
    myIntegerInput.option=0; // Option 0, space pad right, option 1, zero pad left, option 2, space pad left.
    lcd.clear();
    lcd.print("  0 - 20,000ms"); // Prompt user for input
  
    input_integer(&myIntegerInput); // This actually calls the library function to ask user for input. The input is stored in user_input, not the return value. The call supplies the address ("&") of the phi_prompt structure to the library function input_integer.
    
    lcd.clear();
    lcd.print("Frame Inrerval :"); // Display the user choice one more time
    lcd.setCursor(0,1);
    lcd.print(user_input1); // Prompt user for input
    lcd.print(" ms");
    wait_on_escape(4000);
    
}

void top_menu_function_3() //Replace this with the actual function of menu item #3
{

    phi_prompt_struct myIntegerInput;
  
    myIntegerInput.ptr.i_buffer=&user_input2; // Pass the address of the buffer. After library function call, user input will be stored in this variable.
    myIntegerInput.low.i=0; // Lower limit of the number is 0
    myIntegerInput.high.i=500; // Upper limit of the number is 20
    myIntegerInput.step.i=10; // Step size. User choice increments 2 every time you push up and decrements 2 when you press down.
    myIntegerInput.col=7; // Display number at column 7
    myIntegerInput.row=1; // Display number at row 1
    myIntegerInput.width=2; // The number occupies 2 characters space.
    myIntegerInput.option=0; // Option 0, space pad right, option 1, zero pad left, option 2, space pad left.
    lcd.clear();
    lcd.print("# of frames"); // Prompt user for input
  
    input_integer(&myIntegerInput); // This actually calls the library function to ask user for input. The input is stored in user_input, not the return value. The call supplies the address ("&") of the phi_prompt structure to the library function input_integer.
    
    lcd.clear();
    lcd.print("# of Frames is :"); // Display the user choice one more time
    lcd.setCursor(0,1);
    lcd.print(user_input2); // Prompt user for input
    lcd.print(" frames");
    wait_on_escape(4000);
}

void top_menu_function_4()  //Replace this with the actual function of menu item #4
{

    phi_prompt_struct myIntegerInput;
  
    myIntegerInput.ptr.i_buffer=&user_input3; // Pass the address of the buffer. After library function call, user input will be stored in this variable.
    myIntegerInput.low.i=0; // Lower limit of the number is 0
    myIntegerInput.high.i=500; // Upper limit of the number is 20
    myIntegerInput.step.i=10; // Step size. User choice increments 2 every time you push up and decrements 2 when you press down.
    myIntegerInput.col=10; // Display number at column 7
    myIntegerInput.row=1; // Display number at row 1
    myIntegerInput.width=2; // The number occupies 2 characters space.
    myIntegerInput.option=0; // Option 0, space pad right, option 1, zero pad left, option 2, space pad left.
    lcd.clear();
    lcd.print("Steps per Frame"); // Prompt user for input
    lcd.setCursor(0,1);
    lcd.print( "175/mm");
  
    input_integer(&myIntegerInput); // This actually calls the library function to ask user for input. The input is stored in user_input, not the return value. The call supplies the address ("&") of the phi_prompt structure to the library function input_integer.
    
    lcd.clear();
    lcd.print(user_input3); // Prompt user for input
    lcd.print(" Motor Steps"); // Display the user choice one more time
    lcd.setCursor(0,1);
    lcd.print("Per Frame");
    wait_on_escape(4000);
}

Thanks in advance...

Steve...

Good thing you found this problem before writing too much code.

PaulS:
Good thing you found this problem before writing too much code.

Thanks for the heads up, that did the trick...