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 / Topics / led display 0 – 9 with switch

led display 0 – 9 with switch

|

Projects › Projects › led display 0 – 9 with switch

  • This topic has 1 reply, 2 voices, and was last updated 7 years, 11 months ago by GANEEV SINGH.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 30, 2015 at 2:46 pm #4021
    eshwar
    Participant
    #include <REGX51.H>
     
     
    sfr  ldata =0x90;
    sbit rs = P2^0;
    sbit rw = P2^1;
    sbit  e = P2^2;
    sbit sw = P2^3;
    sbit led= P3^0;
    void delay(int x)
    {int i;
    for( i = 0; i<10;i++)
    {
    for(x = 0; x<1250; x ++);
    }
    }
     
    void lcdcmd(unsigned char x)
    {
    ldata = x;
    rs = 0;
    rw = 0;
    e = 1;
    delay(10);
    e = 0;
    }
     
    void lcddata(unsigned char y)
    {
    ldata = y;
    rs = 1;
    rw = 0;
    e = 1;
    delay(10);
    e = 0;
    }
     
    void init_lcd()
    {
    }
     
    void main()
    {
    char i[10] = "0123456789";
     
    char k;
     
     
    lcdcmd(0x38);
    lcdcmd(0x06);
    lcdcmd(0x0E);
    lcdcmd(0x01);
    lcdcmd(0x80);
    delay(100);
    if(sw==0)
    {
    led = 0;
    for( k =0; k<10;k++)
    {
    delay(100);
    lcddata(i[k]);
    delay(100);
    lcdcmd(0x01);
    delay(100);
     
    }
    led = 1;
    }
     
    }
     
     
     
     
     
     
     
     
    February 23, 2018 at 9:07 am #14757
    GANEEV SINGH
    Participant

    Hi

    I find a little problem in this code.

    The code will show nothing on LCD screen if the switch is not pressed at all. According to me, "If(sw==0){}" condition should be written under "while(1)" loop so that it keeps on checking the switch status and displays 0-9 whenever switch gets pressed.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • To couple or decouple February 10, 2026
  • ANOTHER OLD PROJECT REDO February 10, 2026
  • analog logic of shmidt trigger bjt circuit February 10, 2026
  • Buffer design? February 10, 2026
  • XLR splitter to mono. February 10, 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