欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4320|回復: 3
收起左側(cè)

lcd1602光標我怎么控制,我要把光標移到一個地方,然后對某個數(shù)字操作加減

[復制鏈接]
ID:725056 發(fā)表于 2020-4-11 23:34 | 顯示全部樓層 |閱讀模式
lcd1602光標我怎么控制,我要把光標移到一個地方,然后對某個數(shù)字操作加減。代碼應(yīng)該怎么寫,求大神指導一下!
回復

使用道具 舉報

ID:641629 發(fā)表于 2020-4-12 15:58 | 顯示全部樓層
void init()                                                               
{
         RW=0;
         LCDEN=0;
     writeComm(0x38); //顯示模式,
     writeComm(0x0c); //開顯示, 關(guān)光標
     writeComm(0x06); //寫字符后地址加1, 光標加1
     writeComm(0x01); //清屏
}
void writeComm(uchar comm)                              //寫命令程序
{
    RS = 0;   
    LCDEN = 1;
        P2 = comm;
        del_ms(1);
    LCDEN = 0;
    del_ms(1);
}


void writeData(uchar dat)                                         //給1602液晶屏發(fā)送數(shù)據(jù)
{
    RS = 1;
    LCDEN = 1;
        P2 = dat;
    del_ms(1);
     LCDEN = 0;
     del_ms(1);
}
void writeString(uchar *str,uchar length)               
{
    uchar i;
    for(i=0;i<length;i++)
    {
        writeData(str[i]);
     }
}
writeComm(0x80+????);writeData(' ?????');

這里就是定位的光標
回復

使用道具 舉報

ID:641629 發(fā)表于 2020-4-12 15:59 | 顯示全部樓層
另外一種   主要看    LCD_set_xy( uchar x, uchar y )

void LCD_init(void)               //液晶初始化
{
        P1=0xFF;
        P3=0xff;                                //輸出
        LCD_RS=0;                                  //
        del_ms(50);
               
    LCD_write_char(0x30,0);
    del_ms(6);
    LCD_write_char(0x30,0);        //
    del_ms(1);
    LCD_write_char(0x30,0);        //上電即顯示正常,無需復位        
    del_ms(1);
    LCD_write_char(0x02,0);
    del_ms(1);
    LCD_write_char(0x28,0); //4bit test顯示模式設(shè)置(不檢測忙信號)
    del_ms(1);  
    LCD_write_char(0x08,0); // 顯示關(guān)閉
    del_ms(1);
           LCD_write_char(0x01,0); // 顯示清屏
    del_ms(1);
    LCD_write_char(0x06,0); // 顯示光標移動設(shè)置
    del_ms(1);
    LCD_write_char(0x0C,0); // 顯示開及光標設(shè)置
    del_ms(10);
}
//---------------------------------------------
void LCD_write_str(uchar X,uchar Y,uchar *s)
  {
    LCD_set_xy( X, Y );         //寫地址   
    while (*s)                          // 寫顯示字符
      {
        LCD_write_char( 0, *s );
                s ++;
      }
  }
  void LCD_set_xy( uchar x, uchar y )  //寫地址函數(shù)
  {
    uchar address;
    if (y == 0) address = 0x80 + x;
    else
       address = 0xc0 + x;
    LCD_write_char( address, 0 );
  }
//------------------------------------------------
void LCD_en_write(void)          //液晶使能
{
  _nop_();
  LCD_E=1;//EN=1
  _nop_();
  LCD_E=0;//EN=0
}
//------------------------------------------------
void LCD_write_char(uchar cd,uchar ab) // 寫數(shù)據(jù)
{
delay_nus(20);
if(cd==0)
{
  LCD_RS=1;                                  //RS=1,寫顯示內(nèi)容  
  LCD_byte(ab);
}
else
{
  LCD_RS=0;                                   //RS=0,寫命令
  LCD_byte(cd);
  }
}
//-----------------------------------------------
void LCD_byte(uchar abc)//
{
        delay_nus(50);
        if(((abc<<0)&0x80)==0)         //MSB is output first
         LCD_D7=0;                      //abc=0
         else LCD_D7=1;                 //abc=1
        if(((abc<<1)&0x80)==0)         //MSB is output first
         LCD_D6=0;                      //abc=0
         else LCD_D6=1;                 //abc=1
        if(((abc<<2)&0x80)==0)         //MSB is output first
         LCD_D5=0;                      //abc=0
         else LCD_D5=1;                 //abc=1
        if(((abc<<3)&0x80)==0)         //MSB is output first
         LCD_D4=0;                      //abc=0
         else LCD_D4=1;                 //abc=1
        LCD_en_write();
       
        if(((abc<<4)&0x80)==0)         //MSB is output first
         LCD_D7=0;                      //abc=0
         else LCD_D7=1;                 //abc=1
        if(((abc<<5)&0x80)==0)         //MSB is output first
         LCD_D6=0;                      //abc=0
         else LCD_D6=1;                 //abc=1
        if(((abc<<6)&0x80)==0)         //MSB is output first
         LCD_D5=0;                      //abc=0
         else LCD_D5=1;                 //abc=1
        if(((abc<<7)&0x80)==0)         //MSB is output first
         LCD_D4=0;                      //abc=0
         else LCD_D4=1;                 //abc=1
        LCD_en_write();
                
}
回復

使用道具 舉報

ID:514901 發(fā)表于 2020-4-12 16:36 | 顯示全部樓層
LCD寫命令模式,第一行是0x80+列位置,第二行是0xc0+列位置
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表