• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeProjectNumber puzzle with Arduino
Previous Next

Number puzzle with Arduino

Posted by: Olva , October 16, 2016
IMG_20160904_213016.jpg

Hi friends, today want to share this single project. It is about a number puzzle game with arduino, which the game is displayed on the Tv and controlled by a keypad of (4×4)

 

For sliding or moving the square of the puzzle, press the key according of the position of the square desired. For example, as shown in the picture, if you want to move the square with the number 5 (which has the fourth position) to the left (because there is a empty position), press the key ‘4’ in the keypad, because it is the fourth position in the keypad.

If you like this project please vote for it in the puzzle contest.

 

Step 1: List of components

Picture of List of components

The materials used for this project are:

  • Arduino One or another model.
  • TV with video output.
  • RCA video cable.
  • (1) 1k ohms resistor.
  • (1) 470 ohms resistor.
  • Hex keypad.
  • Jumpers.

Step 2: Connecting Arduino to the Tv

Picture of Connecting Arduino to the Tv
rca2 - copia.jpg
Esquematico_arduino.JPG

 

First, add the resistors inline to some hook up wire.

The RCA cable will have 2 wires in it, a ground wire and a video wire.

The 1k ohm resistor is connected to the pin 9 of Arduino.

The 470 ohm is connected to the pin 7 of the Arduino.

Join the ends of the resistors, and connect it to the video cable.

The GND wire of the RCA cabl goes to GND of the Arduino.

If you have problem in the compilation, extract the 3 folders in the library folder.

Step 3: Connect the keypad

Picture of Connect the keypad
Arduino pin KeyPad
13 Row 0
6 Row 1
5 Row 2
4 Row 3
3 Col 0
2 Col 1
1 Col 2
0 Col 3

Assemble the project as shown in the picture.

Step 4: The code

Picture of The code

The numbers (1 to 16) are stored in an array.

The number 16 represents the empty position.

For shuffling the numbers, press the key ‘A’ (at the start of the game), this calls a procedure which shuffles the numbers in the array, and later are shown in the screen.

When you press some key in the keypad, the program verifies if there is some empty position in the near position

(left, right, up or down). As shown in the picture: If the key ‘1’ is pressed, verifies the near positions.

switch(key)
{

case ‘1’:

change(0,1); //The array(0) position, checks the array(1) position.

change(0,4); // The array(0) position, checks the array(4) position.

break;

…………

The CHANGE function exchange the numbers in the array and the screen it is updated with the numbers.

The game ends when the array it is in the correct order: {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}

 

 

The original post is from

instructables.com/id/Number-Puzzle-With-Arduino/

Share!
Tweet

Olva

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors