Interactive Family Game
I know that it may not look like much, but this little box is actually a very fun family night activity. It basically acts as an interactive game board that supports up to 12 players. The greatest part is that everyone plays from their mobile device. The game is super fun, family friendly and fun for all ages.
I will say before you get into this project, you do need some background knowledge. I will provide code and basic instructions but I can not teach you how to troubleshoot any issues you may encounter, and I won't dive deep into setting up a LAMP webserver on your Raspberry Pi. With that being said, I hope you are willing to take on the challenge and follow through these steps to build this game!
Supplies
The most important things that you will need are a Raspberry Pi (I used the 3 B) and an electronics kit for the led light setup. The links are posted below.
Aside from these things, you will also need the following:
1' X 1' Canvas - $6
1' X 1' Plywood - $3
Portable phone charger - $12
Hinges - $2
Latch - $2
How Is the Game Played?
This game is based off of a game that I have played with my family for years. Basically you write down the name of every person who is playing the game and put them in a bowl. Everyone draws a name and the name you get is the name you play as for the rest of the game. The goal of the game is to fill the winning couch with people on your team.
When setting up the game, you leave one seat vacant and this determines whos turn it is. If you are to the left of the empty seat, you say any name of the people playing, and the person who was assigned that name has to get up and move to the empty seat. You keep doing this until one team gets all of their players onto the designated winning couch.
Switching gears a little bit, this project that we will be building mimics this game almost exactly, however it is played without moving and from the players phone. In this project we will be building a website that divides the players into teams, assigns a character to them, and allows for the players to take turns with the goal of knocking people off of the game board.
Setting Up a LAMP Web Server on Your Raspberry Pi
As I mentioned earlier, I will not be getting into this part of the project too much, I just expect that you already know how to do this. If you do not know how to do this, then have no fear, you can check out this video. It really is not that hard to do, and a few google searches and youtube videos should get you on your way. So lets get your pi set up, and move on the the more entertaining parts of this project.
Permissions
One of the biggest headaches that you are going to run into with getting this thing to work, is getting the permissions in order. By default, you will not have the permissions to run python files in the apache server with PHP code. To fix this, you need to give www-data the proper permissions. Open terminal and enter 'sudo visudo' then enter. This brings up the /etc/sudoers.tmp you need to add www-data at the bottom with permission. Refer to the images above.
When you update that file, exit and save and everything should work properly.
Set Up the Breadboard With All the Lights
If you are not familiar with how to use a breadboard, I have made a diagram that shows exactly where everything needs to plug into. There is also a map above of the GPIO pin layout on the raspberry pi and it will show you which pins can be used as a switch. The ones labeled with GPIO are the ones you want to go for. It also shows the pins that are grounds and it is important to note that you will only need 2 of those, one for each side of the breadboard.
You will want to set up 8 lights in total, 4 red and 4 blue. Put the blues on one side of the bread board and the reds on the other side. Once these are set up, we will be getting into the code to make the game work, and function on the web.
Transfer PHP Code and Python Code From Google Drive to Raspberry Pi
This step is going to be the most important and will also have the most bugs and that is I why I recommend you study php and python a little bit before doing this project. I have made it easier for beginners however by providing you with all the code that you will need for the project. Click on the google drive link below to get started.
What you are going to want to do is copy all of this code to a flash drive, and move it to your pi. You will then want to overwrite your www file in your apache web server with this new www file to move the game onto your raspberry pi. If you run into apache permission errors, then just copy the html file into your www file and make sure to get the connect.php file from the google drive www file and paste it into your www folder. This should be a fairly simple process but don't be alarmed if you run into bugs. I recommend using the var/apache2/error.log to figure out any issues you may run into.
Mount the Components and Decorate
Congratulations you have made it! This is the final step that you will need to do for this project. First things first, you need to mount all of your components to a slab of plywood. This will include your raspberry pi, your breadboard and your battery. Make sure you run all of your lights from the bread board up to the surface of the game board with GPIO jumper cables.
After that it is a matter of decorating your canvas. I personally chose to paint it, but you are only limited by your imagination here. The final step is to add the hinges and latch to connect your components with the decorated game board.
Now that you have everything put together, I think that it is worth mentioning that this game only works off of a web server and so you will need to go to your browser on your phone and type, {the raspberrypi ip address}/game.php. When you do that, you and your group should be able to start the game from there! Note, everyone must be on the same wifi as the raspberry pi if they want to play.
You are done! I hope that you were able to get this built and I hope that you have fun playing this game with your friends and family!