SelectionList from oli kraus

Hi there, i need some help in this SelectionList sketch from oli kraus. I tried use just regular tactile switches with a 10K pulldown or pullup resistor but it didn't work out for me. i use a Mega2560 Pro Mini from epalsite. it would be nice if somebody could help me. thnx

sketch_sep18b.ino (3.53 KB)

It would be nice if someone would simply post their code.

Alright Sir :slight_smile:

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);


void setup(void) {

  // U8g2 SH1106 Proto-Shield
  //u8g2.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 7, /* menu_up_pin= */ 6, /* menu_down_pin= */ 5, /* menu_home_pin= */ 3);

  // DOGS102 Shield (http://shieldlist.org/controlconnection/dogs102)
  // u8g2.begin(/* menu_select_pin= */ 5, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 2, /* menu_up_pin= */ U8X8_PIN_NONE, /* menu_down_pin= */ U8X8_PIN_NONE, /* menu_home_pin= */ 3);
  
  // DOGM128 Shield (http://shieldlist.org/schmelle2/dogm128) + DOGXL160 Shield
  //u8g2.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 3, /* menu_prev_pin= */ 7, /* menu_up_pin= */ U8X8_PIN_NONE, /* menu_down_pin= */ U8X8_PIN_NONE, /* menu_home_pin= */ 8);
  
  // MKR Zero Test Board
  u8g2.begin(/*Select=*/ 0, /*Right/Next=*/ 1, /*Left/Prev=*/ 2, /*Up=*/ 4, /*Down=*/ 3, /*Home/Cancel=*/ A6); 

  // Arduboy
  //u8g2.begin(/*Select=*/ A0, /*Right/Next=*/ 5, /*Left/Prev=*/ 9, /*Up=*/ 8, /*Down=*/ 10, /*Home/Cancel=*/ A1); // Arduboy DevKit
  //u8g2.begin(/*Select=*/ 7, /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ 8); // Arduboy 10 (Production)

  u8g2.setFont(u8g2_font_6x12_tr);
}

const char *string_list = 
  "Altocumulus\n"
  "Altostratus\n"
  "Cirrocumulus\n"
  "Cirrostratus\n"
  "Cirrus\n"
  "Cumulonimbus\n"
  "Cumulus\n"
  "Nimbostratus\n"
  "Stratocumulus\n"
  "Stratus";

uint8_t current_selection = 1;


void loop(void) {

  current_selection = u8g2.userInterfaceSelectionList(
    "Cloud Types",
    current_selection, 
    string_list);

  if ( current_selection == 0 ) {
    u8g2.userInterfaceMessage(
  "Nothing selected.", 
  "",
  "",
  " ok ");
  } else {
    u8g2.userInterfaceMessage(
  "Selection:", 
  u8x8_GetStringLineStart(current_selection-1, string_list ),
  "",
  " ok \n cancel ");
  }
}

Please post the code that you tried

Its the code up there. like i said i tried with 10k pull up and pull resistors it didn't work. But strangely it worked with this keypad

4x4-Matrix-Keypad-Keyboard-Tastatur-Modul-16-Tasten-8-LED

but only the red keys which is pulled down by 10K resistors and connected with red LED's. I just wanted to use it with 4 keys for my project. I was going to make first the buttons work then modify the code for my needs.

As far as I can see the code that you posted does not read any input pins either singly or from a keypad. Can you please explain where in the code they are read ?

UKHeliBob:
As far as I can see the code that you posted does not read any input pins either singly or from a keypad. Can you please explain where in the code they are read ?

I actually have no clue how Oli did this..lol, but it works flawlessly on the keypad.

now I uncommented this line and tried this.

// U8g2 SH1106 Proto-Shield
u8g2.begin(/* menu_select_pin= / 2, / menu_next_pin= / 4, / menu_prev_pin= / 7, / menu_up_pin= / 6, / menu_down_pin= / 5, / menu_home_pin= */ 3);

and it works with the following pins 2,4,7,6,5 on the keypad as well.