• 液晶显示zxf


    #include <reg52.h>
    #define  uint unsigned int
    #define uchar unsigned char
    /* ***************************
    PIN 
    *************************/
    #define LCD1602_DB P0// 
     sbit LCD1602_RS=P2^5;
     sbit LCD1602_RW=P2^6;
     sbit LCD1602_EN=P2^7; 
    /* 
    *****************************
    */
    void LCD1602_check_busy(void)
    {
        unsigned char sta;
        LCD1602_DB=0xff;
        LCD1602_RS=0;
        LCD1602_RW=1;
      do
        {
            LCD1602_EN=1;
            sta=LCD1602_DB;
            LCD1602_EN=0;
        }while(sta & 0x80);
    }
    void wrcmd1602(char cmd)
    {
        LCD1602_check_busy();
        LCD1602_RS=0;
        LCD1602_RW=0;
        LCD1602_DB=cmd;
        LCD1602_EN=1;
        LCD1602_EN=0;
    }
    void wrdata1602(char mdata)
    {
        LCD1602_check_busy();
        LCD1602_RS=1;
        LCD1602_RW=0;
        LCD1602_DB=mdata;
        LCD1602_EN=1;
        LCD1602_EN=0;
    }
    void LcdSetCursor(unsigned char x,unsigned char y)
    {
      unsigned char addr;
        if(x==0)
            addr=0x00 + y;
        else
            addr=0x40 + y;
        wrcmd1602(0x80+addr);
    }
    void LcdShowStr(unsigned char x,unsigned char y,unsigned char *str)
    {
        LcdSetCursor(x,y);
        while(*str!='')
        {
            wrdata1602(*str++);
        }
    }
    void InitLcd1602()
    {
        LCD1602_RW=0;
        LCD1602_EN=0;
        wrcmd1602(0x38);
        wrcmd1602(0x0c);
        wrcmd1602(0x06);
        wrcmd1602(0x01);
        wrcmd1602(0x80);
    }
    void LCD1602_cls()
    {
      LCD1602_check_busy();
        LCD1602_RS=0;
        LCD1602_RW=0;
        LCD1602_DB=0x01;
        LCD1602_EN=1;
        LCD1602_EN=0;
    }
         
    /* 
    ***************?÷oˉêy**************
    */
    void main()
    {
    
      InitLcd1602();
        LCD1602_cls();
        LcdShowStr(0,0,"    Hello!zxf");
        LcdShowStr(1,0," Hello!");
     
        while(1);
    }
    归去来兮
  • 相关阅读:
    关于MYSQL 和INNODB的逻辑关系图。最好的理解是一点点动手做,观察,记录,思考。
    MYSQL的DOUBLE WRITE双写
    MYSQL 中binlog 参数的记录
    How to install pip
    gdb
    vim的基本使用
    012_fieldset.html
    010_header.html
    011_label.html
    008_img.html
  • 原文地址:https://www.cnblogs.com/zoute/p/8032939.html
Copyright © 2020-2023  润新知