Blog - Sketching with Hardware

Confuseball – Team 6

Published on: | Author: Sandro Gauß | Categories: 2016a, Best Projects, Projects

Since we’re both big foosball fans, it didn’t take us a lot of time to decide what to implement on this years topic „Circuit Board Games“: A foosball game 2.0

After doing some Brainstorming we decided that our foosball game needs to have two main features. The first and most important one, is the electronic goal counting. We solved the problem with a closed current circuit. When the ball hits the goal, the current circuit will be open for a short time. The Arduino recognizes this change of the circuit and sends a signal to the Android smartphone, which counts the goals. Furthermore the Arduino sends a signal to the green LEDs above the goals, which begin to flash for five times.


The other main feature is the so called Action-Mode. If a player pushes a little button, a background LED switches from green to red and the ground begins to wobble, because two servos begin to turn around.

Another feature is the ball-tracking done in the Android smartphone app. It recognizes a red ball using the OpenCV library and sends this data to a small web-application, where the position of the ball and the score are shown. Also it plays some sounds, for example when a striker is about to take a shot at the goal.

What you need to build Confuseball:

  • Arduino with USB cable
  • 2 Servos
  • 4 green LEDs
  • optional: 4 RG LEDs
  • 2 Buttons
  • 14 Resistors (6x 68 Ohm, 8x 309 Ohm)
  • Cables
  • Copper tape
  • Foam
  • 2 pieces of plastic to cover the goals
  • 2 metal springs to fasten the plastic
  • Nails/Screws
  • Selfie Stick
  • Android Smartphone with OTG support and mobile Internet
  • PHP Webserver
  • and -of course- a foosball game


Technical Details

Now you have all the electronical stuff to build „Confuseball“, but how to build it together?


At first we take the foosball and cut around 4mm of the field on each side away. Because in the end we want the field to be able to wobble. Now we try to build the goal.

First you take the piece of plastic and make some copper tape on it, also on the inner side of the goal because you want to get a connection for a closed current circuit between the two parts. To combine the tape with the electricity of the Arduino, the heart of the project, you have to solder a cable on the copper tape. For more stability of the piece of plastic you take, for each goal, one metal spring to fasten the plastic. If it is not solid and the current circuit isn’t closed you can put some foam between the plastic and the metal spring.


Moreover you should insert the green LED above the goal, so you can flash them when somebody shoots a goal. It is very important to solder one of the resistors of 68 Ohm on the positive pole of each LED. We decided for a parallel circuit of two green LEDs on each side of the goals. After you build the LEDs and your goal sensor you can begin to take all parts of the foosball together.


We cut the field, so we don’t need the groove in the side of the foosball. As you can see in the pictures we put the cables inside of it. We used it as a cable duct 🙂

Now we finished the hardware part for the goals and the LEDs, but we want the field to wobble, so we have to build in the servos and the buttons. Furthermore we wanted to have some LEDs below the field. But we’re going to begin with the servos. Take one side of the foosball and fix the servos below, so that when they move, they should wobble the field with their cogwheel. We also have to fix the field with some nails or screws around the table. The cables you can put in the cable duct. Maybe you have to bore a hole from the goal side to the groove. In the and you have all cables at one side and you can plug them in the Arduino. I think it’s better to take them together and use different colors. For example, we glue the three cables of the servos together, so in the end we don’t have problems keeping apart all the different cables.


To activate the servos we build in mini buttons between the screws of the foosball on the side. We bore a hole and put the cables through. Then we combine the cables with the button and the other side goes to the Arduino. We fix the cables with some tape and put them in the hole.


After that, we build a bracket for the background LEDs out of wood. For the background we take 4 RG-LEDs. They light green all the time, without the „Action-Mode“. In this mode they change the color from green to red and the field begins to wobble.
swh2016a_9Don’t forget the resistors, now you need for each LED 2 ones, because you have a green and a red positive pole. For these LEDs we take 309 Ohm resistors. We combine them to form a parallel circuit. You can find more information in the circuit layout.

Now we have a lot of cables which we have to combine and plug in the Arduino. First of all you sort them. A good idea is to plug them in the breadboard first. After you combine all cables successfully, you can start to solder them on a printed circuit board. The reason is: you have only a little space and the breadboard is too big. Furthermore it could be possible that the cables don’t fit in the pins and you get lots of errors. In the next step you can put your circuit board and the Arduino in the foosball.


It’s time to fix the selfie stick at the foosball. We take some pieces of plastic and fasten it with two nails. Now you can plug the selfie stick into the plastic rings. On the top of the stick you have your phone with our Android App and connected over OTG with your Arduino, which shows you the score, tracks the ball and then send the information to a web application. In our web application the score and the ball tracking are displayed. (If you want more information on how to connect your Arduino to an Android smartphone, go to our other post).

swh2016a_layoutI promised to show the circuit layout. Don’t be afraid of the cables, it is really easy and everybody can
understand this plan. Important are the colors of the cables, red is positive and black is negative. We will start at the digital pin 2. There is a gray cable which checks whether the current circuit is closed or open at the goal. But why we do we need at this point a resistor with 68 Ohm? It’s called a pull down resistor and you need it to make sure, that in the cable is no more „power“. Without it, it’s possible that there is a little power and the Arduino thinks the circuit is closed. Anyway trust us, we checked it out and lost a lot of time 🙂

If you follow the black cable from the end of our gray cable, you will come to our goal and then to a red cable, which ends in the positive pole. That’s it. The whole technic of the goal 😉 At the digital pin 4 you have the same construction for the other goal.

Let’s check out the digital pin 3. It is a red cable and combines one positive pin of the RG-LEDs. I think this is the pin for the green light. Don’t forget the resistor between the positive cable and the LED. The negative pin ends in a black cable, which is linked in the negative pole. You also can combine all black cables to one cable. Next digital pin on the Arduino is pin 4, we already talked about it, also digital pin 5. It’s pretty easy, it’s the cable for the red background light. Everything is analog to the digital pin 3. In digital pin 7 and 8 are the buttons. The orange cable goes to the button and on the other side a black cable to the negative pole. Now when the button is pressed, there will be power and the Arduino recognizes this. Normally you need another pull down resistor too, like at the goals, but you can solve this with a little bit code and have no more work with any resistor 🙂 The digital pins 9 and 10 are the servos. Servos have 3 cables, one is red for the positive pole, the second is mostly black (but every time dark; in our case it was brown – in the circuit layout black) and you have to plug it in the negative pole. The last one is for the information, what the servo shall do. So you put it in the Arduino, in the circuit layout the cables have the color yellow. The last two pins (12 and 13) are for the green goal LEDs. Follow the red cable from the pin and you will come to the resistors (68 Ohm). This is also a parallel circuit like the background LEDs. Both negative poles of the LEDs go to the negative pole on the breadboard. Now we have all pins connected, but one thing is missing. Yes, you have to connect the negative and positive pole on the breadboard with the Arduino. We take the 5V output of the Arduino, so that the servos get enough power.

That’s it with the whole electric stuff! 🙂
Now build all parts together, set the field on the nails and the servos, build in the players and very important take some foam and glue it on the side of the goals. Otherwise it is possible to shot on the wall and the Arduino thinks that you shot a goal

The best thing in the end… your power comes from the Android smart
phone, so it is possible to play outside, for example at the English garden in Munich.


Arduino source Cod

You can download the code by clicking on the link below. In the beginning
you should initialize all constant pins. For example in pin 2 should be the goal A const int inPinTeamA = 2;. You also have to initialize the servos and their start positions Servo myservo1; int pos = 0;. The goal status is set on 2 int teamAscored = 2;,so they’re neither on (1) or off (0) in the beginning. Don’t forget to set the button information. We initialize a const delay value so you can only activate the „Action-Mode“ every 30 seconds and a buttonStateTeamX value, which we set to 0 (not pressed).

Next we have to define the pins in the setup() Method, which kind of pins they are, for example INPUT or OUTPUT pins. After the settings begins the code in the loop(). This is the heart of the Arduino code. The Arduino recognizes if somebody shoots a goal, or wants to activate the „action-mode“. Furthermore all information, which the Arduino gets, it sends to the Android device. With digitalRead(inPinTeamA); the Arduino checks at the Pin (inPinTeamA = 2) if there is some changes. In this case, it checks if there is power or not. So if there is no Power (if (teamAscored == LOW)) the Arduino goes into the if-Case and lets the green LEDs flash and sends an „A“ to the Android App Serial.write(„A");. Same thing for the other goal. Also to the action button is „listend“ every time, and the Arduino recognizes any changes. If it is pressed, it sets the background LEDs from green digitalWrite(ledPinBigGreen, LOW); to red digitalWrite(ledPinBigRed, HIGH);, it also sends a message to the smartphone. With the For-loop the Arduino moves the servos. pos is the current position , so the servo moves from 31 to 149 with only one step. After the step, it should wait for 30 milliseconds. The integer how the servo should move, was very swh2016a_Arduinodifficult to attempt to find out. But with a little bit try-and-error it turned out well 🙂 At the end of the
function, the background LEDs switch to green. Furthermore there is a delay of 30 seconds, so you have to wait 30 seconds until you can push the button again.

Here you can check out the Arduino code and the source code of the Android App and the web application!

Link to the web application.


Features – Little Overview

After building the whole electronic and software your foosball is hacked. It has some nice features. First you don’t have to count the goals any longer. Every goal is registered by the Arduino. If it recognizes a goal, the green LEDs are flashing and the app will count it and display the score.

Moreover the app sends the information to the web application and your friends can see the live tracking and score 🙂

„Action-Mode“ is the next feature: Push the button. Now the game is more difficult, because for the next 30 seconds the ground is wobbling

linked categories 2016a, Best Projects, Projects


Write a comment


[…] our project „Confuseball“ we used it to receive a notification on the smartphone (and from there it was forwarded to a web […]