Help making lcd menu with submenu's using 4x4 keypad

Hi

I am breaking my head here, i’m trying yo make main-menu with sub-menu’s and entering with a 4x4 keypad, i have done this before (about 15years ago)
But i cant remember a thing from it… And the laptop i used then, is way gone, so are the relevant files i had.

The project is to drive 1 steppermotor for a certain length, send a ready signal for a press, then wait for new startsignal etc.
I need the possibility to chance the length,speed and accel settings, plus put in a number a counter.

Here is my “script” for the menu (written for my selfe, to ease the coding, but…)

I use an 4x4 keypad an a 1602 i2c lcd, that is configured and it works, but not integraded to my steppermotor code yet.

I imagine that *=Return and #=Enter, ABCD not active (Unless A & B should be used for JOG?)

Main menu; “Length: xxx,x mm” // X= selected length
“Count (yyyy) zzzz” // Y=selected count, Z= actual count

By pressing “#” jump to sub menu 1

Sub menu 1: “JOG Press 4=Fwd” // JOG only possible in this menu.
“Press 6=Reverse” // jogfwd,jogrev

By pressing "#"we jump to sub menu 2, Or “*”=Main menu without saving

Sub menu 2: “Curr. Length xxx,x mm” // Enter a length between 0-999,9 mm
“Set Length = ???,? mm”

By pressing "#"we save the new input and jump to sub menu 3, Or “*”=Main menu without saving

Sub menu 3: “Counter: yyyy” // Enter a number between 0-999
“Set counter ???”

By pressing "#"we save the new input and jump to sub menu 4, Or “*”=Main menu without saving

Sub menu 4: “Speed ???” // Enter a number between 0-999
“Acceleration ???” // Enter a number between 0-999

By pressing "#"we save the new input and jump to Main menu 4, Or “*”=Main menu without saving

The system will only “RUN” when Main menu is active (ready=high when?)

I have a code that drives a single steppermotor, that works, but i dont have any hmi, so i have to connect my PC
everytime i need to change length, etc.
I have been reading about a thousand pages about menus, but i dont seem to find anything that matches my project?

i really hope someone can point me in the right direction.
Thank you
// Palle

Heres the code for my steppermotor:

#include <AccelStepper.h>
AccelStepper stepper(1, 11, 10); // Define stepper funktion(1) og step(11) dir(10)
int startsignal = 12;
int ready = 13;
void setup()
{
pinMode(startsignal, INPUT );
digitalWrite(startsignal, HIGH);
pinMode(ready, OUTPUT );
digitalWrite(ready, LOW);
}
void loop() {
digitalWrite(ready, HIGH); //ready
if (digitalRead(startsignal)==LOW){ //wait for input to go low
digitalWrite(ready, LOW); //
stepper.setMaxSpeed(200); //set speed
stepper.setAcceleration(20); //set acceleration
stepper.moveTo(1000); // set length
stepper.runToPosition(); //run until steppermotor reach position
stepper.setCurrentPosition(0); //zero position, speed, maybe also acceleration?

}
delay(10);
}

Search Forum for Arduino + menu. This is an old question.
There is no “universal menu code”. It depends on how the menu tree is supposed to be like.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.