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 / My english is very bad I can

My english is very bad I can

|

Microcontroller › 8051 › Help me to create a 16×2 LCD display in AT 89s52 › My english is very bad I can

April 7, 2011 at 1:31 pm #5923
chuduc
Participant

My english is very bad I can not express their answers, Here is my code written for lcd16x2, hope it is for your help

 

#include “reg52.h”
const unsigned char clr=1,home=2,d_on=15,d_off=12,set=56;
sbit     rs=P2^0;                     
sbit     rw=P2^1;                     
sbit     e=P2^2;                      

/*  P0 noi voi LCD data
     noi 3 bit thap cua P2 voi chan cam LCD_CONTROL
     co the su dung board thi nghiem 89_v2 de chay chuong trinh
     cac lenh su dung:
    int_lcd();        cai dat lcd
    lenh(clr);        xoa lcd
    lenh(home);        dua con tro ve dau dong
    lenh(d_on);        mo display,blink
    lenh(set);        che do 16×2
    dat(1 ki tu);        xuat 1 ki tu ra lcd
    dat_str(“chuoi”);    xuat 1 chuoi ki tu ra lcd
*/

void delay(unsigned int msec)  // chuong trinh con tao thoi gian tre ms
{
    int i,j ;
        for(i=0;i<msec;i++)
        for(j=0;j<1275;j++);
}
//


void busy()    //chuong trinh con kiem tra lcd co ban ko
{
    rs=0;
    rw=1;
    P0_7=1;                          
    while(P0_7!=0)
    {
        e=0;
        e=1;
    }
}
//


void lenh(unsigned char ma)    //chuong trinh con xuat lenh len LCD
{
    busy();

    rs=0;
    rw=0;                        
    e=1;
    P0=ma;
    e=0;
}
//


void dat(unsigned char ma)    //chuong trinh con xuat du lieu len LCD
{
    busy();
    
    rs=1;
    rw=0;        
    e=1;
    P0=ma;
    e=0;
}
//


void mov(unsigned char row, unsigned char col)    //chuong trinh di chuyen con tro
{
    lenh(128 | (row << 6) | col);    //row =0 la hang dau,=1 la hang 2
}
//


void dat_str(unsigned char *str)    //chuong trinh xuat ra LCD mot chuoi ki tu
{
    while (*str!=’’)
    {
        dat(*str);
        str++;    
    }
}
//


void int_lcd()    //chuong trinh con cai dat LCD
{
    delay(2);                    //doi 2ms
    lenh(set);                    //8bit, 2 line
    //lenh(d_on);                      //display on, cursor on,blinking on
    lenh(d_off);                       //display on,cursor off,blinking off
    lenh(clr);                    //clear display
    lenh(home);                    //return home
}
//


void main()
{
    int_lcd();
    lenh(home);
    dat_str(“chu nguyen duc”);
    while(1);
}

 

I‘ll post the schematic tomorrow,If any problem please contact me: [email protected]. Goodlucky!!:D

RSS Recent Posts

  • Help please! BLDC driver circuit using the IR2136s and the STP80NF06 MOSFETS November 8, 2025
  • need two ICs November 8, 2025
  • MLT-8530 Buzzer on ESP32: Why Is the Sound Output Lower Than Expected? November 8, 2025
  • Scope Clock CRT Z-Axis - Grid bias positive? November 8, 2025
  • Measuring controller current output with a meter November 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

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