Manual entering of 4 single-digit numeric values.

An Arduino Mega 2560 Rev 3 will be used.

Four separate values will be entered and retained indefinitely in flash memory and will be referenced by a sketch. Four momentary push buttons, one for each value, to step through 0 to 9 for each value, will be used. A 5th button to 'save' the final value of each button will be used. A seven-segment LED, common to all four values, could be used for display as each value is stepped in.

Upon power on, the sketch will run utilizing the values previously entered. If a button is pushed, the sketch would be interrupted to accommodate entering of the new value(s).

Is there a more reasonable technique to use to enter the four values? Is there an existing sketch available to do this?

Thank you for the help,
Frank

How will You decide, ask for the numbers or use stored numbers when You start from cold?

The numbers left the previous time will be used. Typically, the numbers that had already been entered would be used. I just need a way to change them when necessary.

Thanks Railroader!

BTW: I was with the Santa Fe / BNSF for about 36 years !!

What you propose is entirely reasonable, but the task could be done with just two or three buttons: for example, a "value select" button, an "increment value" button, and "enter value" button.

You will want to use the EEPROM on a standard Arduino, not flash memory. Arduino provides functions for reading and writing to EEPROM.

So the goal is to have a 4-digit number you can set. Using five input buttons is not an unreasonable design. I take it that the 5th button just stores the number for future reference. You will want to store it in EEPROM since FLASH can't be written by an Arduino program.

frankpc:
The numbers left the previous time will be used. Typically, the numbers that had already been entered would be used. I just need a way to change them when necessary.

Thanks Railroader!

BTW: I was with the Santa Fe / BNSF for about 36 years !!

Okey.

The flow of the code could be like this: At start up show the last stored number. Pressing "accept" will use it. Pressing any other key will initiate entering a new number sequence input.

frankpc:
BTW: I was with the Santa Fe / BNSF for about 36 years !!

I got it. Nice!

I've been a licensed amateur train engineer in a museum railroad for 50 ears...

frankpc:
An Arduino Mega 2560 Rev 3 will be used.

Lots of power and resources but it will work well.

Is there a more reasonable technique to use to enter the four values? Is there an existing sketch available to do this?

**I suggest to create a flow chart how the logic will proceed, from power up and how to run until power down/reset. **
/quote]

jremington:
What you propose is entirely reasonable, but the task could be done with just two or three buttons: for example, a "value select" button, an "increment value" button, and "enter value" button.

You will want to use the EEPROM on a standard Arduino, not flash memory. Arduino provides functions for reading and writing to EEPROM.

OK. So I would use the "Value Select" button to select the digit (1-4), the "Increment" button to increase the digit value (0-9), and the "Enter Value" button to save the new value(s) in EEPROM. Saves 2 buttons! Great advice.

Railroader:
Okey.

The flow of the code could be like this: At start up show the last stored number. Pressing "accept" will use it. Pressing any other key will initiate entering a new number sequence input.

Really, the numbers won't change often and the project will be used by people who will want to just turn the thing on. So I'm hoping they will only push any of the programming buttons when they desire to change the buttons. Do you think that would work?
Do you folks know of any sketches that would already do these types of things?
thank you for the advice and help.

frankpc:
Do you folks know of any sketches that would already do these types of things?

Before asking for code ready for You (it doesn't exist) You need to tell a lot better how the the human interface would look like.

Railroader:

frankpc:
An Arduino Mega 2560 Rev 3 will be used.

Lots of power and resources but it will work well.

Is there a more reasonable technique to use to enter the four values? Is there an existing sketch available to do this?

**I suggest to create a flow chart how the logic will proceed, from power up and how to run until power down/reset. **
/quote]

I was thinking I would need more IO pins than a Uno. But I am probably wrong. The project will have two 7-segment digits (each about 2 ft tall and 1 foot wide). So I was planning not to multiplex them. Rather to drive each of the 14 segments separately. Probably a bad idea. Then I thought about using selector switches for the values. I know that was a bad idea. So maybe a smaller Arduino will work.
So you are suggesting writing the sketch from a flow chart. I'll give it a shot. I've done a small amount of Arduino programming. But stuff like de-bounce routines and interrupt routines are things I haven't messed with.
Thank you!
PS -- In California, Missouri, Kansas, and Illinois, I've seen model RR's that are elaborate and the owners take great care with their design. Seems like maintenance is the problem because the caretakers aren't their fulltime.

Railroader:
Before asking for code ready for You (it doesn't exist) You need to tell a lot better how the the human interface would look like.

OK. thanks!!
I'll work on it RRr,
Frank

Quite a lot, quite a mix.

Instead of 66 buttons 2 dials could be used telling which area is selected. Could even be analog, using 2 analog inputs.

How to solve various I/O is not really interesting at this point. Work out of the logic, what input and what output will be used in the respect of logics, not hardware. The info.... not the hardware is the way to do it.

Do you folks know of any sketches that would already do these types of things?

The Arduino IDE comes with the State Change Detection example, which shows you how to read a button and increment a count.

Files>Examples>02.Digital>StateChangeDetection

jremington:
The Arduino IDE comes with the State Change Detection example, which shows you how to read a button and increment a count.

Files>Examples>02.Digital>StateChangeDetection

Great. I didn't know what terminology to use. State Change Detection works well. Thanks.

Railroader:
Quite a lot, quite a mix.

Instead of 66 buttons 2 dials could be used telling which area is selected. Could even be analog, using 2 analog inputs.

How to solve various I/O is not really interesting at this point. Work out of the logic, what input and what output will be used in the respect of logics, not hardware. The info.... not the hardware is the way to do it.

I considered using analog inputs, but I was concerned that if they got bumped or got dirty, their values could change.
I wondered whether some sort of selector switch existed that would allow the selection of 1 of 10 positions. But that might require 11 input pins (??)
Thanks!

I wondered whether some sort of selector switch existed that would allow the selection of 1 of 10 positions. But that might require 11 input pins (??)

These 10 position selector switches are often used with resistance ladders and the position determined by analogRead() on one pin.

Here is a link to a sparkfun tutorial on how to do this.

https://learn.sparkfun.com/tutorials/rotary-switch-potentiometer-hookup-guide

@cattledog
Just what i had in mind. 2 pins, one per digit.

cattledog:
These 10 position selector switches are often used with resistance ladders and the position determined by analogRead() on one pin.

Here is a link to a sparkfun tutorial on how to do this.

Rotary Switch Potentiometer Hookup Guide - SparkFun Learn

I suppose what would happen is either I'd have to have four of those, or I would have to use one with a second selector to choose which of the four digits was being changed.
Thanks!

To select a 2 digit value, 2 knobs, 10 position switches would do the job.
Hold down one of 4 selector switches, dial the number and release the selector button.....