need help

can someone download my code and give me some advice on runing my menu and the array
call engine() works but repeats array
want to move on to next menu item after runing the array
any help would be greatly appreciated. thank you tom

keypad_tom23.ino (3.86 KB)

want to move on to next menu item after runing the array

You can't "run the array". What is that supposed to mean?

  if(Item1 == menu.getCurrent())//;
  //else;
 { 
    
   {
  if(Item2 == menu.getCurrent())
 { 
  if(Item3 == menu.getCurrent())
  {
  //  lcd.print(engineSpeed);
  } 
 }
  }
}

}

I suggest you use the auto-format feature in the IDE. That is unreadable. I'm guessing you just threw in extra "}" symbols until the compiler error messages went away.

  if(used.item==Item1);
    Engine();

http://www.gammon.com.au/forum/?id=12153#trap13

the array runs putting 4 numbers to the serial monitor under item1 menu will program to 2 line or lcd
but trying to get this nto work first. the problem is the a button on the keypad use.menuroot
b button moves down the menu change menu item
c button moves up the menu
a them become menu.use
(used.item==item);
engine();// runs the array
but sometimes the array runs before menu.use
sometime the array under menu item, 2.3, 4
sometimes 2 arrays numbers then a item then the rest of the array
and repeats the array.
want to save the array to eeprom and send it to another arduino one to transmit and one to receive for train engine. hope i made this a litter clearer. thanks tom

the array runs putting 4 numbers to the serial monitor

NO IT DOES NOT. Code runs. Functions get called. Functions do things. Arrays DO NOT RUN.

tom1947: the array runs putting 4 numbers to ...

Did you reformat your code as @Nick Gammon suggested?

...R

Did you follow the link I gave? Are you listening to us?

thank you for the help i think the problem is with calling a fuction return; not sure how to return nothing or if i want to return some value, and how to set it up thanks again tom read the web site new at this still have a lot to learn

ran the auto format here is the new code haven’t learn enoght about fuction, function engine runs but
don,t know way the menu functin and engine are running at the same time want the keypad to first
then menu.use, run engine function return to readkeypad then move up or down the menu
do it all over again fo the next menu.iteam tom

keypad_tom23.ino (3.92 KB)

tom1947: function engine runs but don,t know way the menu functin and engine are running at the same time want the keypad to first then menu.use, run engine function return to readkeypad then move up or down the menu do it all over again fo the next menu.iteam tom

Thank you for formatting the code. Sorry but I don't understand this comment

Can you describe in plain language (not code) what the program is supposed to to.

...R

i am trying to make a remote control for my ho trains one transmitter one receivrer a pcd board with arduino chip a keypad for input, a wireless board for talking to the receiver, an lcd ,the menu.is to set the commands to the receiver, the engine-id is to set a 4 digital number and save it to eeprom and another menu item to save it to the engine boad, so as to control one engine at a time. set engines with different numbers

reciever to get wirelessn signall run motor and direction. have an h bridge for track polarty

That is useful information but it is not what I was looking for in this case. I would like you to describe in plain language how the program is supposed to work

It seems to me, from a quick look, that your code is wrapped up in itself. There are calls to the Engine() function all over the place and both readKeypad() and Engine() read the keypad. And then there is menuUseEvent() - but what does that do?

Look at the approach in planning and implementing a program where the different activities are dealt with in different functions

I have built my own battery powered radio control system for my N-Gauge trains using very small Arduino devices.

...R

thanks for the web site verry helpfull i rerote the fuctions what do you think
can you follow the program see the coments and give some more advice ,menu use under readkeypad
a button, can i enter data on line 2 lcd. from here or do i have to set up a submenu.
thanks tom

keypad_tom23.ino (4.57 KB)

tom1947: can you follow the program see the coments and give some more advice

You are effectively asking me to reverse-engineer your project. That would be very time consuming.

On the other hand if you provide a description (in plain language) of how the program is supposed to work it would be much easier to make sense of the program.

Also important is to describe clearly what the program actually does and how that differs from what you would like it to do.

If you are having trouble with a menu maybe it would be wise to write a short program just to learn how to make the menu work. I have never used a menu system on an Arduino so I have no obvious comments to make.

...R

    if(used.item==Item1);

Bzzzzt.

It also looks to me like your opening and closing braces don’t match in “loop()”

what i want is to run a menu driven program scrolling up and down the menu. select the id option which is to set up the arduino chip in the train engine. set direction and speed, the trick is to code the engine with a 4 digit cab number another engine with its own number save it. run one engine at a time. lights, sound ect. if mu (multiunit) is seclect run two or more engins by putting in a secondary number. check for engine if correct run engine if not do nothing.

send siginal to engine get responce if correct engine number run if not ingore all outher commands. need to figture out how to program sounds bell, and horn button press for these. respond onlty to correct engine number.

kind of a lot for my first project. angine thanks for the help.

tom1947: what i want is to run a menu driven program scrolling up and down the menu. .....

I suggest you write down the steps of the logic of your project with one step on each line. And it is most important to write them in plain language, not in code. Leave the code for later.

When I start something I am not familiar with my initial planning notes are probably much longer than the code will ever be.

When you are satisfied that you have a clear concept of what needs to happen it should be reasonably simple to turn those steps into code. But without that clear concept the code is just going to be a mess and you will spend ages going round in circles.

...R