Archiv der Kategorie: Arduino

Einfaches Arduino-UserInterface mit 16×2-Display

The English translation may be not complete, since I just started to write bilingual, and also not very good.
While Text-Output on 16×2 Character-Displays with LiquidCrystal is quite easy, input is a little bit harder. Hence you are often coding the parameters hard and flash the arduino for every value new. To expand the lifetime of my Arduino I wrote a little library for simple Input. You need only a display, compatible with the LiquidCrystal-Library, and 5 Buttons (LEFT, RIGHT, UP, DOWN, SELECT) which you can implement as you like.

The mainfunctions are for example a Menu, Numberinput, Textinput and Percentinput. Also the buttons can be accessed easily and assigned functions.

Examples of user



A simple menu where you can chose between entries. You can navigate through it using the UP and DOWN keys. If you have reached the desired entry you can select it with SELECT or RIGHT. Use LEFT to abort.


char *menu[] = {"Entry A", "Entry B", "Entry C", 0}
switch(simpleui.showMenu("Titel", menu)){
   case 0: //Entry A
   case -1: //Abbruch (en: abort)



A function to input percent-values, for example the volume. With LEFT and RIGHT you change in 10% steps, with UP and DOWN in 1% steps. You can set a function, which is called everytime the value changes (to play a sound with the new volume etc.).


int p = simpleui.getPercent("Titel", 63, onVolumeChange);
void onVolumeChange(uint8_t p){
   //Spiele Beispielton


display16x2-textEine sehr primitive Texteingabe wie sie von Spielekonsolen(„Please enter your name“) bekannt ist.  Mit LEFT/RIGHT wird die Position geaendert und mit UP/DOWN das Symbol veraendert. Mit SELECT wird die Eingabe abgeschlossen. Es koennen klein und Grossbuchstaben sowie Zahlen und Leerzeichen eingegeben werden. Ein Erweiterung um die erlaubten Symbole selber zu setzen ist geplant.

char buffer[20];
simpleui.getString(buffer, 20);


display16x2-numberEine relativ schnelle Eingabemethode von Nummern. Ueber LEFT/RIGHT wird der Summand veraendert (Zehnerpotenz 1,10,100,…) und mit UP/DOWN der Summand addiert oder subtrahiert. Mit SELECT  wird die Eingabe abgeschlossen.


int i = simpleui.getUInt();



First you have to initalize LiquidCrystal by creating the specific object. The parameter are the pins for controlling the display. You will find them in the manuals or homepage for your display.
LiquidCrystal lcd(8,9,4,5,6,7);
In the next step you create the SimpleUI16x2-object which you give the LiquidCrystal-object and a function to query the buttons.
LiquidCrystal lcd(8,9,4,5,6,7);
SimpleUI16x2 simpleui(&lcd,getButton);

//The Button function you have to define by yourself
uint8_t getButton(){
	int adc_key_in = analogRead(0);
	if (adc_key_in > 790) return BUTTON_NONE;
	if (adc_key_in < 50) {
		return BUTTON_RIGHT;
	if (adc_key_in < 195) {
		return BUTTON_UP;
	if (adc_key_in < 380) {
		return BUTTON_DOWN;
	if (adc_key_in < 555) {
		return BUTTON_LEFT; 
	if (adc_key_in < 790) {
		return BUTTON_SELECT;  
	return BUTTON_NONE;
Now you should be able to use the UserInterface. You should take a look at the example in the library.



You will find the library in git under

To use the library you have to move the folder SimpleUI16x2 into the folder libraries of your Sketchbook-Folder. If this Folder doesn’t exist yet, you can simply create it. Maybe you also need the LiquidCrystal-Libary, if it is not included in your Arduino-Installation by default.


Die Library befindet sich noch im Aufbau und wird in der naechsten Zeit, ebenso wie dieser Artikel fertiggestellt.