Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • 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
  • 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 Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

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.

  • Can anyone please help me with this single board computer?
  • Anyone successfully communicated to the BlueNRG-M0 module on the B-L4S5I-IOT01A board
  • How to Build an Audio Tone Control?
  • Current version of LTspice not working on Windows 11?
  • Addressable Latch in My Logic Project

RSS Electro-Tech-Online.com Discussions

  • Measuring controller current output with a meter
  • KiCad custom symbol definition correct approach
  • restarting this Christmas project
  • Anyone In The US Ordered From AliExpress Recently?
  • My Advanced Realistic Humanoid Robots Project

Featured Tutorials

Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
    Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
    Practical application of hardware filters with real-life examples
  • A filter design example
    A filter design example
  • Types of filter responses
    Types of filter responses
  • What are the two types of hardware filters?
    What are the two types of hardware filters?
  • What are hardware filters and their types?
    What are hardware filters and their types?
More Tutorials >

Recent Articles

  • Posifa sensors improve low-flow accuracy in compact systems
  • Acopian releases low-profile power supplies rated to 900 W
  • Octavo Systems OSDZU-3 REF Development Platform
  • Same Sky adds enclosure design to its audio engineering capabilities
  • Waterproof SMA-to-MHF I LK assemblies introduced by Amphenol RF

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • 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
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • 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
  • Guest Post Guidelines
  • Advertise
  • Subscribe