Mastermind - Logik (Arduino + LCD 20x4 - I2C)

Hi, I'd like to introduce today my implementation for Mastermind, also known as Logik. In this implementation, the player does not guess the colors and their order as in the original - desktop version played by two players, but guesses the numbers and their order. It should be stressed that numbers cannot be repeated. The task of determining numbers and their order is Arduino, which generates them.

Arduino continues to serve as an experiment counter and receives logic inputs through 5 buttons that switch against the ground (INPUT_PULLUP). Use the buttons to enter the user input in the form of numbers for positions. The last button confirms the entry and sends it to Arduino. In addition to the current user input, the LCD also shows the result.


If the user does not guess the number or the position, the display will show the corresponding position - if he guesses the number with the position, = will be displayed; if he guesses the number but not the position, C will be displayed. uncomment. In principle, it only displays the searched number on the display if the developer wants to test the functionality of the individual elements and to verify whether the game ends after attempting or guessing the searched number.

The game is limited to 10 player attempts. If the number of attempts is exceeded, the game will end with a message about the player's loss. If the player guesses the target number, the game ends with a statement of the player's winnings. The game is not limited in time. In the game, it is also recommended to use pencil and paper to write entries, which can lead to a statistical advantage in finding the target number.
Wiring diagram for Mastermind:

Library for LCD display with I2C expander: GitHub - fdebrabander/Arduino-LiquidCrystal-I2C-library: Library for the LiquidCrystal LCD display connected to an Arduino board.
Program for Mastermind:
https://arduino.php5.sk/mastermind-arduino.php?lang=en

1 Like