Intro: Bulls and Cows Game With Arduino
Also known as Cows and Bulls or Pigs and Bulls or Bulls and Cleots) is an old code-breaking mind or paper and pencil game for two or more players, predating the similar commercially marketed board game Mastermind.
It is a game with numbers that may date back a century or more. It is played by two opponents.
On a sheet of paper, the players each write a 4-digit secret number.
The digits must be all different. Then, in turn, the players try to guess their opponent's number who gives the number of matches. If the matching digits are in their right positions, they are "bulls", if in different positions, they are "cows". Example:
Secret number: 4271Opponent's try: 1234Answer: 1 bull and 2 cows. (The bull is "2", the cows are "4" and "1".)
This time is made for playing against the arduino, which generates 4 random digits that are not repeated.
The player enters its 4 digits through the keypad and press key D to confirm the digits. The lcd displays the amount of cows (is shown as 'puntos' in the video ) and bulls ( is shown as 'famas' in the video) ( the video and project was made for spanish version) that the player gets. After 5 tries you have not guessed the secret number, you lost and the secret number is shown.
Pressing the key 'A' starts a new game.
Pressing the key 'B' resigns the game and shows the secret number.
Step 1: Diagram of the Project
LIST OF COMPONENTS:
- Arduino One or another model.
- Keypad (4x4) or (4x3)
- Display lcd
- Potentiometer of 50k
- jumpers for connecting.
Step 2: The Code
You can download the code in arduino here.
The code ensures there are nor duplicated digits.
Remember that you starts a new game pressing the key 'A' and resigns the game when press the key 'B'
If you have any doubts or suggestions please let me know it.