Electronic Sudoku Game

by TechKiwiGadgets in Circuits > Arduino

8110 Views, 36 Favorites, 0 Comments

Electronic Sudoku Game

1. Lead page 2.jpg
sudokugif.gif
5. Charging.jpg
2 side 2.jpg
2. Top view underside.jpg
6. Assembly.jpg

Calling all you Sudoku addicts...

Play, Create and Solve Sudoku puzzles using this easy to build Arduino based project.

Simple to use with a touch screen and stylus the unit comes preloaded with Sudoku puzzles to play, a help feature to highlight incorrect values and an automated solver button.

This project includes a 3D printed case with only seven components including a USB rechargeable battery so is does not require a high degree of electronics experience to complete.

Gather the Materials

6. Screen off.jpg
Arduino Sudoku Solver Circuit V1.png
Sudoku Solver Play

Years ago, just for fun, I wrote an excel macro to solve Sudoku Puzzles on a desktop computer. It occurred to me that this could be incorporated into an Arduino Touch Screen device. The perfect fit for this was an Arduino Uno and a compatible 2.8 inch TFT touch screen shield.

3D Print the Case

4. Case Print Open.jpg
4. Case print.jpg
Sudoku Solver Print.gif

The 3D case was printed with White PLA with each part oriented so that Lid and Base are facing upwards using the following settings

Layer Height: 0.2mm

Speed: 40mm/s

Nozzle Diameter: 0.4mm

Supports: Enabled

Nozzle Temperature: 210 Degrees

The 3D Model Files are located here on Thingiverse with the touch screen stylus inserts into a cavity under the Arduino PCB and can be removed by sliding out with your finger.

Load the Code and Test the Screen

6. Screen connected closeup.jpg
2. Inside COmponents.jpg

The best place to start is to connect the Arduino Uno with the TFT screen and test the screen. I have subsequently found there are various screens available that have different drivers or settings so here is my recommended approach.

1. Connect the Screen to the Arduino Uno

Carefully align the Arduino Uno and TFT screen pins and ensure they are oriented correctly. In the picture provided, you can see the correct alignment including the noticeable gaps in the Uno and TFT screen pins that help with alignment.

2. Load the Arduino IDE libraries

Firstly download and install the Arduino IDE from here

The code requires the following three libraries to be loaded into the Arduino IDE to enable it to work

3. Calibrate Screen colours and Touch Locations

TFT LCD Screens come with different control chipsets and touchscreen setups. I had quite a challenge with this particular model getting it working and had to make a number of configuration changes before I could get it working satisfactorily.

Fortunately, Adafruit has provided a variety of options to deal with these challenges however you may find some issues you may have to deal with.

Test that the colours and touch locations of the touch screen are consistent with the video and pictures provided.

  • If the screen is not working then you may need to change the screen type in the code to ensure correct operation.
  • If the touch locations are incorrect then row 218 of the code provides test coordinate data which can be used with Row 39 min/max settings for touch accuracy.
  • If the colours are incorrect check they can be changed after row 60 of the code
  • If the orientation of the screen is in portrait then row 105 in code can be adjusted

If problems persist message me and I will try and assist.

I have also included a version of code for the standard ILI9314 display

Build the Circuit and Assemble the Unit

6. Screen connected.jpg
6. Screen Off Components.jpg
6. Charger.jpg
6. Solder Components.jpg
tp4056-circuit.jpeg
3. Internal Assembly.jpg

Circuit assembly is relatively simple. The only two main challenges are to ensure the hookup wire is adequate for the location of devices within the case and ensuring that the Battery does not short out when arranging the components in the case.

1. Modify the TP4056 Charging Circuit

Lithium Polymer batteries require a current limiting charging circuit to avoid overcharging and damage. The standard TP4056 is set to allow up to 1Amp of charge current into a 3.6v battery.

This needs to be changed to below 600mA for this battery and so the existing surface mount resistor needs replacing with a 3.3K resistor.

*** NOTE: This is important as connecting to a USB port without considering charge current will damage the battery and possibly cause an electrical fire. ***

Fortunately, this is a relatively painless process of heating the surface mount resistor and then pulling off with pliers.

Then soldering the 3.3K resistor from GND terminal to Pin 2 of the TP4056 IC. Further discussion on the technique can be found here

I also covered the installed resistor with hot glue to ensure it was insulated.

2. Connect the Battery to the Charger and test
Following the circuit diagram, carefully solder the Li-Po battery to the +ve and -ve battery connectors on the TP4056 PCB.

Make sure all joints are well soldered and any exposed joints are insulated so that there is no chance of shorting them to other components.

Test the battery is charging correctly by connecting the unit to a USB charger through the USB port on the TP4056 board. If working correctly the RED LED should light indicating the unit is charging.

When the battery is fully charged the RED LED should go out and the BLUE LED should light.

If the charger does not operate like this then you need to troubleshoot the issue and resolve before proceeding.

3. Install the Slide Switch

Solder hookup wire to the slide switch as per the circuit diagram and then position the switch into the case and ensure it seats correctly. Use a tiny amount of hot glue to fasten the switch in position firmly within its mounting position.

4. Connect the Charger to the Arduino Uno

Using a soldering Iron carefully connect the Arduino Uno Ground Pin and 5V pins to the output of the TP4056 PCB

5. Mount the Battery Charging Circuit

Position the TP4056 PCB in the lid of the case as per the photo provided. Connect a USB plug into the PCB to hold it in position and check that it is charging correctly. Use hot glue to fasten the TP4056 PCB to the LID while ensuring the USB socket is not covered in glue.

6. Mount the components into the Case

Carefully arrange the Arduino and Screen in the Case. Position the Battery, wiring and switch and close the lid to check there are no obstructions.

Check that the screen is mounted squarely in the unit by checking the full display can be seen when powered up through the lid aperture.

Use hot glue to fasten the Arduino Uno into the correct final position.

Carefully apply hot glue to fasten the case in place. Now you are ready to play Sudoku.

Sudoku Game Play and Operation

1. Lead page.jpg
IMG_20190516_124610.jpg
2 side.jpg
Sudoku Solver - Arduino
Game Play Sudoku Solver - Arduino

There are four buttons on the Sudoku Solver that have different functions which can be used to Play, Create, Learn and Solve Sudoku Puzzles

1. Home Button - Create or Solve Puzzles

This is a blank Sudoku screen enabling you to progressively change all locations and create your own Sudoku Puzzle. It can also be used to manually enter an unsolved puzzle that you want to validate with the "Help" button or solve using the "Solve" button.

2. Play Button

There are 5 preloaded Sudoku puzzles in the code that are of varying degrees of difficulty from easy to difficult which means you can instantly get started on solving a puzzle.

The Solve button will instantly resolve 4 out of 5 of these puzzles however not the 5th!!

As you progress you can use the Help button to validate any changes.

3. Help Button

This will progressively check all squares in the puzzle and highlight for half a second any conflicts in RED. Very useful when you are unsure of changes.

4. Solve Button

This button will attempt to apply 4 formulae to solve the current Puzzle in the Solver. It has proven to solve all "Easy", "Medium" and up to and including most "Hard" level rated Sudoku puzzles. It will not completely resolve all Sudoku puzzles however it will give you a good start. Which is good because we dont want to take all the fun out of the game!

Now over to you to solve some Sudoku Puzzles!!!