找回密码
 立即注册
查看: 300|回复: 1

LCD1602动态双行显示(C语言)

[复制链接]
  • TA的每日心情
    开心
    2024-2-19 18:02
  • 签到天数: 26 天

    [LV.4]偶尔看看III

    11

    主题

    23

    回帖

    84

    积分

    注册会员

    积分
    84
    发表于 2023-11-11 09:02:23 来自手机 | 显示全部楼层 |阅读模式
    IMG_6746.jpeg
    主控芯片:STC32G12K128
    设备型号:LCD1602
    主控芯片及实验箱购买链接:
    KCER001.taobao.com
    强烈推荐P3的仿真器
    ////////////////
    #include "stc32g.h"
    #define uint unsigned int
    #define uchar unsigned char

    sbit rs=P0^0;
    sbit rw=P0^1;
    sbit e=P0^2;

    uchar num;
    uint i;

    uchar code tab1[]="www.stcaimcu.com";
    uchar code tab2[]="KCER001.taobao.";

    void csh_io(){
        P0M1 = 0x00;   P0M0 = 0x00;   //设置为准双向口
        P1M1 = 0x00;   P1M0 = 0x00;   //设置为准双向口
        P2M1 = 0x00;   P2M0 = 0x00;   //设置为准双向口
        P3M1 = 0x00;   P3M0 = 0x00;   //设置为准双向口
        P4M1 = 0x00;   P4M0 = 0x00;   //设置为准双向口
        P5M1 = 0x00;   P5M0 = 0x00;   //设置为准双向口
        P6M1 = 0x00;   P6M0 = 0x00;   //设置为准双向口
        P7M1 = 0x00;   P7M0 = 0x00;   //设置为准双向口   
    }

    void delay(uint ms){
       
        for(ms=ms;ms>0;ms--)
        for(i=150;i>0;i--);
    }

    void delayus(uint us){
        while(us--);
    }

    void wat_data(uchar dat){

        rs=1;
        rw=0;
        e=0;
        P2=dat;
        e=1;
        delay(5);
        e=0;
        delayus(50);
    }

    void wat_ml(uchar tad){
        rs=0;
        rw=0;
        e=0;
        P2=tad;
        e=1;
        delay(5);
        e=0;
        delayus(50);
    }

    void lcd_csh(){
        wat_ml(0x38);
        wat_ml(0x01);
        wat_ml(0x02);
        wat_ml(0x06);
        wat_ml(0x0c);
    }   

    void main(){
        csh_io();
        lcd_csh();   
        for(num=0;num<16;num++){
            wat_data(tab1[num]);
            delay(300);
        }
        wat_ml(0x80+0x40);
        for(num=0;num<15;num++){
            wat_data(tab2[num]);
            delay(300);
        }
        while(1);   
    }
    LED点亮世界🇨🇳
    回复 送花

    使用道具 举报

  • TA的每日心情
    开心
    3 小时前
  • 签到天数: 168 天

    [LV.7]常住居民III

    5

    主题

    49

    回帖

    671

    积分

    高级会员

    积分
    671
    发表于 2023-11-11 10:10:11 来自手机 | 显示全部楼层
    谢谢楼主 !
    回复 送花

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

    GMT+8, 2024-5-17 10:19 , Processed in 0.057999 second(s), 35 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表