EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • 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
  • Advertise
You are here: Home / Replies /   interfacing 2 dig seven

  interfacing 2 dig seven

|

Projects › Projects › How to interface keypad with 8051 microcontroller (AT89C51) ›   interfacing 2 dig seven

August 12, 2011 at 10:21 am #6602
Qaisar
Participant

 

interfacing 2 dig seven segment display with 89C51

 

Compiler:  Keil

Simulator: Proteus

 

C Code:

 

 

#include <AT89X51.H>

unsigned char unit1 = 0;
unsigned char tens1 = 0;

char e = 0;

unsigned char font[10] = 0;

void delay(void)
{
 int i = 0;

 for(i = 0; i < 300; i++)
 {
 
 }
}

void mux(void)
{
int i = 0;

 for(i = 0; i < 100; i++)
 {

 P2 = unit1;
 P1_0 = 0;
 delay();
 P1_0 = 1;

 P2 = tens1;
 P1_1 = 0;
 delay();
 P1_1 = 1;

 

}
}

void decode(void)
{
 unit1 = e % 10;
 tens1 = (e % 100) / 10;

 unit1 = font[unit1];
 tens1 = font[tens1];

}

 

void main(void)
{

// 7 seg (CC) equivalent codes
font[0] = 0x3f;
font[1] = 0x06;
font[2] = 0x5b;
font[3] = 0x4f;
font[4] = 0x66;
font[5] = 0x6d;
font[6] = 0x7d;
font[7] = 0x07;
font[8] = 0x7f;
font[9] = 0x6f;

 while(1)
 {

  e++;
  if(e == 100)
  {
  e = 0; 
  }
  decode(); 
  mux();

  
 }
}

RSS Recent Posts

  • Smart Buoy project May 15, 2026
  • Need Guidance to reduce noise in 3-stage Transimpedance amplifier May 15, 2026
  • Wall Radiator Heating: Efficiency and Placement Questions May 15, 2026
  • Parasitic Draw Question May 15, 2026
  • Phone Charger 5v to 12v May 14, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • 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
  • Advertise