LCD Readout of Categories and Items

Hi, Newbie here!

I'm not very good at coding (yet) and would appreciate your help with my project:

I have 2 mechanical encoders, each with 4-pin BCD output. One (A) has 6 positions and is used to select a category name, while the other (B) has 12 positions and is used to select one of 12 item names in each category (all different). I would like to use a 16x2 serial LCD to display the category name on line 1 and the item name on line 2.

The approach I'm contemplating is:

  1. Connect each encoder's 4 pins to 4 DIs on Arduino and apply VCC to each encoder's common pin.
  2. Scan the DI's every 500ms and store the encoders' position number
  3. Use a lookup table (1x6 array?) to determine the category name associated with encoder A's position number
  4. Use a 6x12 array to determine the item name associated with encoder B's position depending on what encoder A's position was.
  5. Clear the LCD and write the new names to the LCD

Will this work? Do I need two tables/arrays, or will one do?

The lookup table(s) or arrays are fixed; is there a clever way to upload them?

Thanks again!

I see no one has commented on your post, so I will begin. On the encoders, another posting relating to encoders discovered the switches were open between detent positions, so you might have to take that into consideration. Along the same path, you may catch the switch between positions, by just scanning one time every 500 ms. I suggest scanning each set of digital pins perhaps 3 times in the 500ms window and taking any two that are identical. If none are identical, then try again.

I would also do two separate tables. Easier to code for and debug. If all the entries are the same length, there is no need to clear the LCD line.

I would define the digital pins as input pullup and ground the common on the switches. Much less wiring mess!

Paul

Look up PROGMEM, so that you can store your lookup table in program memory (flash).

Something like (untested)
const char PROGMEM Names[4][12][8] = { { "Name1", "Name2", ...} , {...} };