Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

DIY Game: Glow All the LEDs First!

By Gurmeet Singh

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.

 

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
 

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.

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!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What is a loop calibrator? 
  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Measure AC current accurateley (100mA to 10A)
  • 74HC595 creating Fake output
  • What was before microcontrollers ?
  • NEED HELP FOR OP-AMP IN BGR
  • Check undesired substrate mode...

RSS Electro-Tech-Online.com Discussions

  • Sla ir li ion
  • Need a ducted soldering fan for solder smoke extraction
  • Question about ultrasonic mist maker
  • Best way to reduce voltage in higher wattage system?
  • Two 300nH inductor in series, can get higher current?
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering