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 / if you are using Keil micro

if you are using Keil micro

|

Microcontroller › 8051 › INTERFACING LCD TO 8051 BY Qurat-ul-ain › if you are using Keil micro

December 19, 2011 at 3:37 pm #6933
Syed Aameer
Participant

if you are using Keil micro vision

 

then try this code

 

#include<reg51.h>

 

#define lcd_data_port P2

 

sbit rs=P1^0;

sbit rw=P1^1;//better to connect to ground and disable this pin

sbit en=P1^2;

 

void lcd_cmd(unsigned short temp);

void lcd_data(unsigned short temp);

void delay(unsigned int msec);

 

void main()

{

     lcd_cmd(0x38);

     lcd_cmd(0x06);

     lcd_cmd(0x0e);

     lcd_data(‘A’);

     delay(5);

    lcd_data(‘B’);

 

}

 

void lcd_cmd(unsigned short temp)

{

   lcd_data_port=temp;

   rs=0;

   rw=0;

   en=1;

   delay(2);

   en=0;

}

 

void lcd_data(unsigned short temp)

{

   lcd_data_port=temp;

   rs=1;

   rw=0;

   en=1;

   delay(2);

   en=0;

  

}

 

 

void delay(unsigned int msec)

{

   unsigned int i,j;

    for(i=0;i<msec;i++)

       for(j=0;j<1275;j++);

}

 

RSS feed: Recent Posts Recent Posts

  • Portable charger for my mate's new leg October 16, 2026
  • solderless sma screw mounting RF causaliy problem October 15, 2026
  • Almost Very New in PCB / KICAD DESIGN October 15, 2026
  • Delco alternator (12SI) AC-tap - what is the mate to this connector called and where to find it? October 15, 2026
  • Semi-automatic battery handler October 15, 2026

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