A friend and I recently had an idea to mix connect four with beer pong after seeing this video. I did some coding in college (engineering but not electrical) and even taught myself some Python a while back for s's and giggles. So I hit the google and looked into making my own electronic game. Eventually, I stumbled across Arduino and after doing a few months of on-and-off research, I finally bought the Starter Kit so I could start tinkering around. I want to make a prototype as a proof of concept before I make a "finished" product. I'm hoping this community can tell me if:
a) the set up I'm talking about is possible and
b) tell me if my understanding of the various components/code required, as I understand it, works or if I should think differently somewhere (just point me towards the right syntax or built in function or component - I can google).
So, here are the bullet points of my mental progression and other questions:
Connect four is a 6x7 matrix. Since there needs to be two colors, we need a bicolor LED matrix (lets call it 7x7, 6x7 with an additional row "off the board" to indicate what player's turn it is). That means multiplexing three shift outs, one for each color, one for ground.
Players would switch turns. This makes coding easier. It also cuts down on the sensors and inputs. Plus, I'm not sure I understand how the board/processing works enough to figure out how to have "dueling" inputs for made shots.
The bottom of each solo cup would have a IR beam break sensor. I believe it would be good practice to have a divider between each cup's receiver/transmitter pair so that if a ball passes a given pair, the receiver isn't picking up the IR light from one of the adjacent transmitters. See below for more stream of consciousness on the sensor. Each cup's sensor would be tied to a shift in, like the component in the shiftin tutorial. This would use 7 inputs (7 columns) and the 8th input could be a "pass" input. A "pass" input would be a push button that would be pressed if a player's shot was a miss. Also, given that there would be a lot of open pins on the board, the "pass" input could be it's own input.
So shiftin() and shiftout()/multiplexing seem straightforward enough, conceptually, but I feel like I couldn't find a lot of projects that were running these simultaneously. How would the IR beam being broken be able to be "heard" while the board is busy lighting up the matrix? I say "heard" because I think there's a "listen" function, but I didn't see it in relation to the serial shift in stuff. Does the multiplexing take so little time that a beam break would be detected regardless? Assuming the ball passed the beam dead center, it will only break the beam for about 90 milliseconds. I honestly have no idea how fast multiplexing is relative to the input.
For the shift registers, are the clock/data/latch pins the same pin when for both shift in and shift out when using both simultaneously?
I'm not 100% solid on how the beam break sensor works. I couldn't find an explanation on the Adafruit website, but please let me know where to look if I'm missing it. What I mean is, what's the threshold for a IR beam break sensor that makes it jump from 0 to 1 (or 1 to 0)? In the end, I'm just curious if its worth tucking the transmitter half of the pair behind a hole in the cup or something else at the bottom of the cup.
I think ping pong balls a trigger are a little difficult to work with, sensor wise. I've considered using mini basketball hoops/balls instead of solo cups/ping pong balls. I think it would be slightly easier because of the weight of the mini basketballs. I'm not sure it's any more economical though. Because of the weight of ping pong balls I figured IR beam break sensors would be the easiest and most economical (remember I have to buy 7) way to sense the passing of the ball. They only weigh 2.5 grams. If anyone has a better sensor idea, I'd be happy to hear it.
I know Adafruit makes 8x8 LED matrices that would simplify the output half of this, but I plan on turning this into a ~27" wide game board (7 solo cups wide at a minimum), so that little matrix doesn't help me from a prototyping stand point
Well, I didn't really. Way too much text, far too little images. I think you can summarise this in about 50-100 words and one or two images and that way actually get the message across.
Now for your project: you have to go back and create a number of sub-projects.
Make some sketches of the actual game layout, and make sure you're completely clear yourself on how it's played. What player input(s) do you get? What do you want to detect? (mind that's WHAT, not how - the how comes later). What output(s) do you want? How do they link together
That will give you a number of sub projects, you get those working one by one. I see here something like detecting balls going through slots, a display that has to be addressed, and a number of input buttons. That are all sub projects, and there are probably more.
When you got all the parts working, you can integrate them in the whole.
For lighting the matrix, you could consider using an ht16k33 chip. These can drive a matrix of up to 128 LEDs. You could use bi-colour LEDs (3-pin type, not 2-pin). The chip can also scan a matrix of buttons at the same time. Perhaps your ir detectors could even be scanned by the chip as though they were buttons, I'm not sure. The ht16k33 is cheap and available on a breakout board (from AdaFruit and others if I remember). Only 2 Arduino pins needed. The chip will take care of all the multiplexing (and button scanning) which will make your code easier.
Another option to consider is using "neopixel" type leds. These are available in strips, individual PCBs or 5mm style. They can display any colour you want and don't need multiplexing. A single Arduino pin could drive all LEDs.
you have a row of what looks like red solo cups, but under there is a solenoid or a motor and a spring. think pin-ball.
you get the cup for the colum you want
the colored ball is recognised and is too large to fit throug the hole in the bottom of the cup that has the spring/piston/solenoid
the lights for that color, say 3,5,7 ? that are on the table for that cup, these light up in the color of the ball indicating a hit.
the ball is then ejected.
you could make this to set between two tables so the springs hang down.
this is actually much easier than I am describing it.
Like wvmarle suggests, if you read some programming books, it should impress upon you the crucial importance of breaking your program into small, incremental problems, ideally as simply as physically possible. This is my interpretation of the main problems and sub-problems only:
Connect - 4 game
-coding game: have you made a connect 4 sketch? Could you make one which runs purely off the serial monitor and then adapt it such that it can be tested and tweaked?
-how does the game receive data from the beer pong table?
-flagging that a cup has already been used (lit on the grid already)
-multiplexing inputs to display on LED matrix
-multiplexing for colour
-in a very pedantic vein could you not simply have single colour and have a button pressed to allow you to view a specific player's existing positions in the matrix? (1 button per player)
Table
-is there liquid in the cups?
-sensing inputs
-which technology is going to be implemented?
-(my suggestion) could light sensors be used in the bottom of empty cups where the base is only just big enough to hold ball? (Must obviously be empty cups)
-which technology is used to transmit sensing technology?
-does bluetooth/RF technology need to be used for sensor transmission to ensure that no liquid damages the arduino rig (if liquid in cups)
In my opinion there are a lot of potentially exciting aspects to this project, but there is the potential to subdivide this list many times, especially when you actually get into the nitty-gritty of implementation.
if you use a single red solo cup as a channel.
and have a cooresponding colum in your connect 4 game
you can check the color of the ball, then increment the connect 4 column that is associated with that cup and use the light that corresponds to that color ball.
do that for each cup/column.
getting the ball out of the cup, either through a hole in the bottom, like a billiards pocket, or a solenoid like in pin-ball, you would have the same sensor available for each play.
the color sensor only needs two colors so that opens your selection.
to get started, manual extraction (button or hole) of the ball
and manual determination of the 4-in-a-row winner.
as you progress, you can automate any part of the game.
as a thought, you can have all the cups drop the balls into a common return tube.
each cup has a sensor to show that a ball went into the cup.
one color sensor on the return chute to determine ball color.