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 / #include

#include

|

Microcontroller › 8051 › Microcontroller › #include

June 9, 2014 at 9:58 pm #11810
Osama Mohammed
Participant
#include <reg51.h>
msDelay(unsigned int);
 
cmd(unsigned char); //LCD command code initialization 
dat(unsigned char ); // LCD data code initialization 
sbit regs=P2^6;  //name the pin register select of the lcd
sbit enab=P2^7;
sbit rd=P2^5;
 
void LCD_write_string(unsigned char *str)   //store address value of the string in pointer *str
{
    unsigned char j = 0;
    while (str[j] != 0)
    {
        dat(str[j]);      // sending data on LCD byte by byte
        msDelay(100);
                j++;
    }
    return;
}
 
void main (void)
{
cmd(0x38);
msDelay(100);
cmd(0x0C);
msDelay(100);
cmd(0x01);
msDelay(100);
 
while(1)
{
LCD_write_string(“osama”);
msDelay(2000);
cmd(0x01);
msDelay(2000);
 
}
 
}
 
 
cmd(unsigned char value)
{
 P1=value;
 regs=0;
 rd=0;
 enab=0;
 msDelay(500);
 enab=1;
}
dat(unsigned char info)
{
 P1=info;
  regs=1;
  rd=0;
 enab=0;
 msDelay(500);
 enab=1;
}
 
msDelay(unsigned int tdelay)
{
 unsigned int k,j;
 for(k=0;k<=tdelay;k++)
 for(j=0;j<=100;j++);
 
}
 
 
 
 
 
 
 

 
 
 
 
This is a code I used to test the LCD , it is not the code that I use in the project that I am working in but just to test the LCD ,but unfortunately this is not working :(

RSS Recent Posts

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 Arrowfly 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 Arrowfly
Privacy Policy | Advertising

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