Arduino LED Race Game using WS2812B LEDs Strip

(Last Updated On: February 15, 2022)

Arduino LED Race Game:

Led Race Game

Arduino LED Race Game using WS2812b LEDs Strip- Hi Readers, in this article, I will show you how to make LED racing game using Arduino and the WS2812B LEDs Strip in very simple way, if you are a complete beginner no need to worry as I have given all the details that you can follow very easily, so let’s begin to build this project.


What is LED RACE Game?

You have heard of many races before, car race, horse race, and a running race. Here the concept is same but we are not using any human interference here in the game, In fact I can see it’s a race between Light emitting diodes!

Yes you heard that correct, here we are racing against the LEDs, and the length of race depends on the length of the LED strip. I have made one of the amazing LED arcade game in my previous post you can check that HERE.

So as you are clear about the project that we are going to make, we will now see what are the materials that are necessary to build this project



Materials Required

  • Arduino Nano/ Uno
  • WS2812B ARGB LEDs strip
  • LED or Buzzer
  • Jumper wires male type
  • Push buttons x 2
  • Breadboard
  • Soldering iron
  • Arduino IDE and Programming cable
  • Double side tape/ hot glue

Amazon Links:

Arduino Uno

Arduino Nano

WS2812 Led Strip

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


Why ARGB LED strip?

ARGB or known as addressable Red green Blue LED are type of bulbs in which we can choose time and intensity along with color of each LED as per our requirements.

Led Race Game

Above image shows the WS2812B LEDs strip which I will be using in this project, Now you may think how much LED so I need in a strip for my project?

The answer for this question is, it is left to you, I would like to say more the number of LED’s the better the game will be. It’s like longer race track, the lengthy the game more interesting the game will be. In my case I used 240 LED and length of the strip was around 300cm.

One thing to be taken care of here is some LED strips come with very close placing, you can check placement of mine in the below image.

Led Race Game

ARGB strips are controlled by Arduino or raspberry pi and they are completely programmable, Meaning you can generate any colors on single LED in a strip of your choice by sending commands with the help of codes.

So these features make it most suitable for us to make this project.

If you see the image above closely you can see the letter Di, Di means signal input and you should look for this arrow before soldering wires to the strip.

To make the circuit easier I soldered male type jumper wires to push buttons and LED strip, so that these can be connected and removed easily whenever needed.


Circuit Diagram for Arduino LED RACE GAME

Led Race Game

This is very simple circuit diagram, to be more clear here is the explanation.

Push buttons has 4 terminals out of which 2 are common, you can check this by checking the back sides. Rails are connected with each other are 1 side, and one side here will be connected to D7 in the Nano board, where as the other side will be connected to Gnd. Repeat same step for push button 2, but here we are connecting one Pin to D6 and other to Gnd. This completes our controller setup! One switch is for player 1 and other is for player 2.

Now as said before the LED strip comes with 3 terminals, one for +5v supply, one for gnd and other for Signal input. Here we will connect signal pin to A0 of Nano board.

The game indicating option can be done via LED or by piezoelectric buzzer, I used LED here and it is connected to D3.

To make the circuit simple I used a mini breadboard and connected all this common terminals to Gnd and power supply.

One more thing here should be noted here is if you think to use this for a very long time I would suggest using an external power supply. With internal supply the board will have some negative effect as the longer LED strip consumes more current.

Led Race Game

The complete circuit looks like the above image, and now we can add some codes that will make this project work.


Arduino Code for LED Race Game

Before uploading the code to board please check for some important changes that is given below.

Led Race Game

In the second line of code #define MAXLED that asks what is the count of LED in the strip you have to enter the number of LED in your strip, if you use the same number which I use and if there is no such count in your strip this project wont work correctly.

Manually count the number of LED and enter correct values, I have marked the changing area to yellow for easier navigation.

If you want colors other than red and green you can change the color codes in the line #define COLOR1 and #define COLOR2, to make the changes as per your color wish know the RGB code of your colorand add the same in track.color(*your values here in R,G,B format*).

If you are not sure of these and don’t want to change you can keep the same default color.

Now you can upload the code to Arduino, after it is done test the project.

Led Race Game

As you can see from the above image the length of the LED is too long, to get a better view of LED I installed this setup on a wooden table, so the running LEDs are visible.



How to Play LED RACE GAME?

Led Race Game

You can see the setup which I made, You can also use a vertical setup too.

Now we will see how to play this game

Connect power supply to the board, I used usb power supply for demonstration.

There will be 2 players in the game one controls the GREEN LED and the other player controls RED LED, the more frequent you push the buttons the more faster the LED moves.

There are 3 Laps, meaning you should complete total 3 rounds and whoever reaches the last lap first will be the winner of game. And to indicate this at the end entire strip of light will display the color of winner, Suppose red light player is the winner the entire strip glows to red and its same with green also.

This completes our LED RACE game project, if you have any questions you can ask us in the comments we will answer your question as soon as possible.


Watch Video Tutorial:

Coming Soon…

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

%d bloggers like this: