Feature

Digital Tug of War

Darko Špoljarić

Issue 49, August 2021

This article includes additional downloadable resources.
Please log in to access.

Log in

Battle it out with friends and family with this fun Arduino-based game. Find out who has the quickest hands.

Teaching students about microcontrollers, how to code, and other STEM-related syllabus can be made so much easier when you gamify the process. In a small high school in Croatia, they achieved this by designing, building, and coding a digital tug of war project. We caught up with high school teacher, Darko Špoljarić to find out more.

Your students' Tug Of War project looks like a lot of fun, Darko. Before we discuss the project, please introduce yourself and the students involved to our readers.

My name is Darko Špoljarić and I'm 50 years old. I live in Slatina, a small town in continental Croatia. I'm an electronics engineer and I teach in local high school. Slatina is a small town of about 12,000 inhabitants so the school is also quite small. It only has about 400 students.

The students who created this project attend the vocational program of electronics and their names are Luka Predrevac, Josip Maroš and Mateo Šerer. They are 18 years old.

Out of interest, when are students introduced to electronics and coding in high schools in Croatia?

These students attend the vocational program of electronics which they start at the age of 17 (second grade of high school). Coding is a part of the regular program and Arduino is a part of the extra-curricular activities program in our school.

It’s great to see coding part of the regular syllabus. What was the motivation in designing and building the Tug of War project?

A game of tug of war is sometimes played at different social events or summer camps. So, we came to an idea to turn this game into the digital form. Gamification should be a very important component in education so we decided to learn something through game.

Agreed. Gamification is a great way to motivate students. What are the differences between the two builds we see in your supplied photos?

Prototype with the added LCD screen

The differences between the first and the upgraded build were in the LCD display we added to the original version that shows the score. We also added two 7-segment displays for the countdown. We built the case for LCD display by printing it on the 3D printer.

It looks like you have used commonly available components?

We used Arduino Nano (or Uno), WS2812B addressable LED strip, two push buttons, LCD 1602 with I2C, two 7-segment displays (common cathode), 4 resistors 1k, jump cables, MB-102 solderless breadboard protoboard, soldering station, 3D printer.

Please tell us how it works.

The game is based on the Arduino platform, and we used the Arduino Nano because of its smaller dimensions and the sufficient number of pins we needed for connection. We connected an LED strip to the Arduino Nano, and we placed buttons on both sides of the strip to turn on the diodes.

We also added four 1k resistors to the circuit for the LED displays.

Scores for Red (Crveni) and Blue (Plavi)

To make the game as attractive as possible on the Arduino Nano, we also added an LCD display that shows the result in the textual form, but also counts down the seconds until the start of the game.

We designed and printed the housing for the LCD display on the 3D printer. Before we added the buttons, we also installed two 7-segment displays that count down the time until the start of the game. Power is provided via a USB cable that connects to a computer port (5V to power the Arduino and the entire circuit). We used a wooden board onto which we placed our game.

The code for the game is our original design. There is one player on each side of the board, one of whom plays as red and the other one as blue. This game is adapted to digital form in such a way that two players each press their own button. The red and blue lights turn on or off depending on the speed of each player and the faster that one player presses his button, the faster the progress on the LED strip. The game continues until one player, the red or the blue one, reaches the end of the strip or until one color dominates the entire strip. The current result is then displayed on the LCD.

How many LED segments are used in your design? We assume it could be adapted to different number of LEDs?

WS2812B Addressable LED Strip

We used 1 metre of LED strip which contains 30 diodes (15 diodes for each player), but more diodes can be used.

Our plan for the future is to create the same game on the larger scale of four metres, 120 diodes.

We see you used an Arduino Uno in the prototype. What made you choose an Arduino Nano for the main build?

We used Arduino Uno in the solderless protoboard but we realized that the Arduino Nano was a better choice because of its smaller dimensions and the sufficient number of pins we needed for connection.

What gets displayed on the LCD screen?

The screen displays the score and before the game begins it displays information about the authors and the name of the game. The text is in Croatian but it can easily be adapted in the code to any other language.

Students also get to work on their woodwork skills

Be sure to drill a hole that suits the diameter of your pushbutton switch

A deep channel underneath the timber helps conceal any wiring

The early prototype with Arduino Uno board

The LED striplight is installed inside an aluminium channel with lens cover to diffuse the light

All the fun maker tools to make the project

It’s great to see that it is custom coded? Was this an easy process?

The original creator of the code is Mateo with my guidance. I have to say that he is a very talented student and that it took him about three hours to create it but I guess it would take more time for somebody who is not well acquainted with coding.

What kind of prototyping was required?

Prototyping using a Nano breakout board and solderless breadboard

The prototype was done with the help of solderless breadboard and we tested all the elements on it before soldering. Josip and Luka were mostly in charge of this part.

Was there any issues with the switches debouncing and causing erratic input, and what design challenges did you need to overcome?

We didn't have any issues with the switches debouncing.

While talking about the project before we started creating it, we had a clear idea of what we would like it to be. So, we didn't have to face any challenges. The upgrades after the first version were pretty obvious to us.

If you were to start over again, would you do anything differently?

Testing with a 3m long LED strip.

The only change that we would make is the size of the push buttons in that we would make them bigger and, as I already said, we would use a longer LED strip with more diodes.

If any of our readers want to make one for themselves is there anywhere they can access the necessary files?

Yes, we are willing to share all the necessary information for you to put in the article and on your website.

Many thanks, Darko. Is there anything we haven't covered that our readers should know about?

I would like to point out that we are only beginners at Arduino and the whole project is the result of the enthusiasm of my students and me.

Please congratulate your students on a great project and thank you for sharing it with our readers.

Darko Špoljarić

Darko Špoljarić

Electronics Engineer & High School Teacher