Skip to content

Example 01: Basic

Alexander Spiridonov edited this page May 17, 2024 · 14 revisions

Additional documentation for an example supplied with the GEM library that demonstrates basic usage of a library.

About

This example demonstrates creation of simple one page menu with one editable menu item associated with int variable, one with bool variable, and a button, pressing of which will result in int variable value printed to Serial monitor if bool variable is set to true.

More detailed walkthrough of this example can be found in Readme (AltSerialGraphicLCD version, U8g2 version and Adafruit GFX version).

Cyrillic version of this example (for U8g2 version of GEM only) can be found here.

Highlights

In this example it will be shown how to:

Schematic and Breadboard

This example relies on the Test bench configuration (AltSerialGraphicLCD version, U8g2 version and Adafruit GFX version).

Sketch

Annotated sketch is supplied with the library and can be found at:

Additional Cyrillic version of this example is available for U8g2 version of GEM at "examples/U8g2/Example-04_Basic_Cyr/Example-04_Basic_Cyr.ino".

Simulator

Simulation of this example (using U8g2 version of GEM) is available on Wokwi. It is possible to interact with the simulation using mouse or keyboard: keys w, a, s, d, e, q are bound to the corresponding buttons on the breadboard (make sure to focus simulation window by clicking on it first).

Run

After compiling and uploading sketch to Arduino, wait while LCD screen boots and menu is being initialized and drawn to the screen. Then start pressing the push-buttons and navigate through the menu. Pressing "Ok" button (attached to pin 7) will trigger edit mode of the "Number" variable, or change state of "Enable print" option, or invoke action associated with "Print" menu button (depending on which menu item is currently selected). If "Enable print" option is checked, then pressing "Print" button will result in number variable printed to the Serial Monitor.