Bulls and Cows Game With Arduino

Introduction: Bulls and Cows Game With Arduino

About: My name is José Luis Bejarano Vásquez.Tecnólogo en electrónica, estudiante de ing electrónica, desarrollador de software. Aficionado a la robótica. Blogger.

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.

Step 1: Diagram of the Project

LIST OF COMPONENTS:

  • Arduino One or another model.
  • Keypad (4x4) or (4x3)
  • Display lcd
  • Potentiometer of 50k
  • Breadboard
  • 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.

Full Spectrum Laser Contest 2016

Participated in the
Full Spectrum Laser Contest 2016

Be the First to Share

    Recommendations

    • Explore Science Challenge

      Explore Science Challenge
    • Box Challenge

      Box Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest

    Comments

    0
    9000612
    9000612

    5 years ago

    nice project welcome to the instructables community