# Bulls and Cows Game With Arduino

1,479

10

1

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".)

Play video (in spanish)

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.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Diagram of the Project

LIST OF COMPONENTS:

• Arduino One or another model.
• Display lcd
• Potentiometer of 50k
• jumpers for connecting.

## Step 2: The Code

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.

## Discussions

nice project welcome to the instructables community