Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

DIY Game: Glow All the LEDs First!

By Gurmeet Singh January 2, 2021

This is a 2 player game, based on 8051 microcontroller AT89S52. This game features two push buttons (one for each player) and an array of 8 LEDs for each. It demands high reflexes, as you have to push button as fast as you can. Each press would help the successive LED to glow until all the 8 LEDs are on.

The competition is about how fast you can toggle (Press and then un-press) the buttons, greater your speed of pressing push button, greater will be your chance of winning. As soon as any of the two players reach the last LED, the push button of another player will get deactivated, which means it will not respond to the push. Also the LEDs of the winner will start toggling. This will ensure the accurate after results. To restart the game, press the reset button (button connected to pin 9 on microcontroller).

Prototype of 8051 Microcontroller based Fastest LED Game

Fig. 1: Prototype of 8051 Microcontroller based Fastest LED Game

Image showing gameplay of Fastest LED Game

Fig. 2: Image showing gameplay of Fastest LED Game

LEDs corresponding to PLAYER 1 are connected to PORT 2 whereas for PLAYER 2, LEDs are connected to PORT 3. Push buttons are connected to pin P1.1 and P1.2 for PLAYER 1 and PLAYER 2 respectively. I have used integer variables “pressed[0] and pressed[1]”(in coding part) to ensure that microcontroller counts only those push which are done after the release of the button. This will ensure fair play.

I have also declared an array arr[], which comprises the hexadecimal values for the LEDs to glow successively. I have also created a delay function: delay_msec(), using TIMERS to provide delay (in milliseconds) wherever necessary.

Since 8051’s cannot multitask, thus to judge the 2 players individually I have written the code in such a manner that it seems to perform multitasking. This was needed to count each and every perfect push and hence result in a fair decision game.

Components & Applications

REQUIREMENTS:

  1. AT89S52 (8051 microcontroller)
  2. 16 LEDs (8 for each player)
  3. Two good quality push button (small)
  4. 1 Crystal:- 11.0592MHz
  5. 7805 voltage regulator
  6. One 9V DC battery

APPLICATIONS:

·         This can be used as a platform for two players to make a fare decision out of their contradicting views(it’s similar to tossing up a coin and making decisions, but with an electronic touch to it).

·         This can also be used a usual game for children to enjoy and practice up on their reflexes.

 

You may also like:


  • What are different types of industrial robots?

  • How does LoRa modulation enable long-range communication?

  • How to play tune for any song or music on…

  • What are the different types of EV charging connectors?

  • What is the role of embedded software in electric vehicles?

  • How to make a decorative coconut tree using a digital…

Project Source Code

###

#include
sbit B1=P1^1;
sbit B2=P1^2;
int arr[]={0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
void delay_msec(int time)
{
int i=0;
while(iwhile(TF1==0);
TR1=0;
TF1=0;
i++;
}
}
void main()
{
int i=0,j=0,pressed[2]={0,0};
B1=B2=1;
P1=0x00; P2=0x00; P3=0x00;
while(1)
{
 if(B1==0 && pressed[0]==1)
{delay_msec(20);pressed[0]=0;}
if(B2==0 && pressed[1]==1)
{delay_msec(20);pressed[1]=0;}
if(B1==1 && pressed[0]==0)
{delay_msec(20);pressed[0]=1;
P2=arr[i];i++;
if(i==8)
{ P2=0x00;
while(1)
{P2=~P2;delay_msec(150);}
}
}
if(B2==1 && pressed[1]==0)
{delay_msec(20);  
pressed[1]=1;
P3=arr[j];j++;
if(j==8)
{ P3=0x00;
while(1)
{P3=~P3;delay_msec(150);}
}
}
}}

###

 


Circuit Diagrams

Circuit-Diagram-8051-Microcontroller-Based-Fastest-LED-Game
Circuit-Diagram-8051-Microcontroller-Based-Fastest-LED-Game_0

Project Video


Filed Under: Electronic Projects
Tagged With: 8051, 8051 microcontroller, game
 

Next Article

← Previous Article
Next Article →

Comments

  1. [email protected] says

    October 21, 2023 at 1:05 pm

    do you have the circuit diagram of this that is not in proteus so i can see the nodes? thankyou!

    Log in to Reply

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Voltage mode pushpull is a nonsense SMPS?
  • Input impedance matching network
  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Reducing "shoot-through" in offline Full Bridge SMPS?

RSS Electro-Tech-Online.com Discussions

  • Is AI making embedded software developers more productive?
  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe