Arduino Game "NIM"

by Dzefri in Circuits > Arduino

9985 Views, 35 Favorites, 0 Comments

Arduino Game "NIM"

16388486_951944434936292_719265526_o.jpg
16409658_951943674936368_1076584329_o.jpg
16326577_951944034936332_1127638942_o.jpg

I got my inspiration form the game Dr.Nim which is plastic toy with mechanism, but it works same as Nim.

Nim is a game with 12 balls, If is your turn you can pick 1,2 or 3 balls and then your opponent plays. The winner is the one who takes the last one.

If you want to learn more about Dr.Nim you can check it out HERE, and if you are interasted in Nim you can read abaut it HERE.(*Nim and Dr.Nim is not same thing)

I made my version with arduino nano,and with lots of plywood, there are two controlers(they are same) and they have 2 buttons and switch, you can turn lights on controler with switch. When you press "play" button motor will push ball and it will come down.

Next button is used when you want to end your turn, but you cant end it if you didn't took at least 1 ball(you can take 3 max).Indicator shows you how many balls left for you to take and winner indicators shows winner.

It is not realy easy to make so if you are just starting with arduino you should get some expiriance before this, but you can download code if you want to try it.

It is cheap and fun project, it took me araund one week to finish this project.

Making Base

IMAG0250.jpg
IMAG0249.jpg
IMAG0253.jpg
IMAG0254.jpg
IMAG0287.jpg

I made a sketch of it, but I calculated bad, so I fixed it 2 times. It is designed so it will work on angle araund 50°.

When make base, cut pieces of wood and make wall araund holes, you need to make them so balls won't stuck or fall trough gap between base and lower base.

So if you are making something you should be sure that mesures are right or you will end up in problems like me. :P

Making Lower Base

IMAG0258.jpg
IMAG0261.jpg
IMAG0263.jpg
IMAG0255.jpg
IMAG0256.jpg

This is part that goes under base and here goes motor and little block that pushes balls (block is connected to servo). Just use plywood of same dimensions as base and cut line for motor to move block, make shure that you cut right size line or you might have problems.

Ball Indicator for Base

HTd3p.png
IMAG0257.jpg
IMAG0265.jpg
IMAG0268.jpg
IMAG0288.jpg
IMAG0289.jpg
IMAG0317.jpg
IMAG0344.jpg
IMAG0349.jpg

Drill holes where to glue balls and LEDs goes behind them.

I added those pieces of wood to isolate light from jumping to wrong ball.

You can wire them like any regular LED but I used transistors, there is scheme how I wired them, same way I did in this project.

I used transistors to power LEDs with another power source, not arduino, you should do this because arduino wont have enough current for all things(If you are using a lot of components you need to power for example).

Add Motor to Lower Base

IMAG0271.jpg
IMAG0273.jpg
IMAG0274.jpg
IMAG0281.jpg
IMAG0275.jpg
IMAG0276.jpg
IMAG0277.jpg
IMAG0278.jpg
IMAG0279.jpg
IMAG0280.jpg
IMAG0285.jpg
IMAG0282.jpg
IMAG0286.jpg
IMAG0369.jpg
sweep_bb.png

I took some gears that could fit and I used it to move block that pushes balls. Plate with gears needs to be connected with block and attach gear to servo so it moves it.

Wire servo like any other (I added scheme, just in case you need it).

But you should power it with another power source, it will work better that way(just connect GND of arduino to GND of power source and positive of power source to servo).

I used pin 5 for servo.

Controllers

IMAG0298.jpg
IMAG0292.jpg
IMAG0309.jpg
IMAG0301.jpg
IMAG0302.jpg
IMAG0303.jpg
IMAG0310.jpg
IMAG0314.jpg
IMAG0312.jpg
IMAG0313.jpg
IMAG0373.jpg
IMAG0338.jpg

Just make the little boxes that are right size and drill holes for buttons.

I added red LEDs to sides of controllers just to make them more cool (They are wired like this 5V-Switch-LED-GND).

Later I added LED for "turn" on each controlers

Wirring

arduino_serial_communication_2_buttons_scheme.png

This is how I wired all buttons I used in this project(In controllers and in bottom part) .

Just be careful for controllers, you should wire 10k resistors behind USB connectors(I wired them inside controllers and I realized that won't work).

Bottom

IMAG0306.jpg
IMAG0308.jpg
IMAG0323.jpg
IMAG0324.jpg
IMAG0320.jpg
IMAG0343.jpg
IMAG0342.jpg
IMAG0322.jpg

I cutted plywood and glued all components(That green LEDs are for indicating player"turn").

All the wiring in this project is simple, so if you have some experience there should be no problems.

Connect Base and Lower Base

IMAG0358.jpg
IMAG0363.jpg
IMAG0364.jpg
IMAG0365.jpg
IMAG0366.jpg

I made few squares, glued them in place(Lower base) and drilled holes in them for screws.

Be sure to cut hole for indicator wires.

Making Conectorc for Bottom and Base

IMAG0375.jpg
IMAG0408.jpg
IMAG0376.jpg
IMAG0377.jpg
IMAG0381.jpg
IMAG0382.jpg

I mate these to connect all removable parts with screws, If you have any better option then do that.

Assemble Bottom

IMAG0385.jpg
IMAG0386.jpg
IMAG0387.jpg
IMAG0388.jpg
IMAG0389.jpg
IMAG0395.jpg
IMAG0409.jpg
IMAG0412.jpg

Just glue all parts(except back plate) and wire all switches like others.

Transistors you see next to the USB jack are used as switches for LEDs.

Wire all switches like others.

DC connector is for back plate, I used female and male headers next to DC connector so the back plate would be removable.

Make Connector for Arduino

IMAG0383.jpg
IMAG0397.jpg
IMAG0384.jpg
IMAG0427.jpg
IMAG0392.jpg
IMAG0393.jpg
IMAG0404.jpg
IMAG0398.jpg

I used female and male headers to connect everything.

Transistor that you can see on pictures is used for winner indicator, LEDs on indicator are wired to turn LEDs, but they will only be ON if transistor is ON (In other words, it is just like switch that switches GND on and off).

Assemble Evrything

IMAG0396.jpg
IMAG0400.jpg
IMAG0413.jpg

Connect evrything with connectors and screws. Drill holes in connectors that you made and screw things together.

Winner Indicator

IMAG0421.jpg
IMAG0420.jpg
IMAG0423.jpg
IMAG0424.jpg
IMAG0433.jpg
IMAG0425.jpg
HTd3p.png

Wire LEDs with transistors like you wired it for ball indicator. You will need 2 of them.

I used 220omh resistors for LEDs and transistors, maybe they are not perfect for them, but they work.

Drill the holes in the place you want top put it and drill the hole in lower base for wire.

Add Reset Button and Wire Other Buttons

IMAG0441.jpg
IMAG0418.jpg
IMAG0419.jpg
IMAG0407.jpg
IMAG0410.jpg
IMAG0411.jpg
IMAG0426.jpg
IMAG0437.jpg

It goes like this GND-Button-RST pin (It is that simple). I added this button so I don't need to turn it on and off every time I want to play again. And you don't need to add anything in code for this to work.

Code

It is dumb device, it means it have no senzors and no way to know how many balls are left, It counts that by how many times you pressed play button.When it caunts 0 the winner is picked(The guy who played last).

I made this code, and you are free to download it, change it or do whatever you want with it.

It may not be the best, but I tried my best.

If you see some mistakes in code or something you would change, please notify me.

Downloads

Finishing Touches

IMAG0449.jpg
IMAG0446.jpg
IMAG0447.jpg
IMAG0448.jpg
IMAG0445.jpg
IMAG0443.jpg

I added little pieces of wood around the middle of base and lower base (Just for the looks).

I used soldering iron to write down all things, but some of them turned out bad so I made few little wooden squares and glued them in place.

Done

16409110_951943644936371_1171173603_o.jpg
Igra sa Arduinom - Game with Arduino

If you want to see video of it working, you can find it HERE.It is not on english but you can see that game works.

I did not made that video, so I didn't wanted to include it in this instructables (My professor made it).

I wanted to make video of it but I don't have good enough camera for It, so if I ever make video, I will add it here.

If you want to see more projects follow me. Thanks :-D