1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉
標題:
lcd1602光標我怎么控制,我要把光標移到一個地方,然后對某個數字操作加減
[打印本頁]
作者:
噠勞德
時間:
2020-4-11 23:34
標題:
lcd1602光標我怎么控制,我要把光標移到一個地方,然后對某個數字操作加減
lcd1602光標我怎么控制,我要把光標移到一個地方,然后對某個數字操作加減。代碼應該怎么寫,求大神指導一下!
作者:
liuxuhe
時間:
2020-4-12 15:58
void init()
{
RW=0;
LCDEN=0;
writeComm(0x38); //顯示模式,
writeComm(0x0c); //開顯示, 關光標
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液晶屏發送數據
{
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(' ?????');
這里就是定位的光標
作者:
liuxuhe
時間:
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顯示模式設置(不檢測忙信號)
del_ms(1);
LCD_write_char(0x08,0); // 顯示關閉
del_ms(1);
LCD_write_char(0x01,0); // 顯示清屏
del_ms(1);
LCD_write_char(0x06,0); // 顯示光標移動設置
del_ms(1);
LCD_write_char(0x0C,0); // 顯示開及光標設置
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 ) //寫地址函數
{
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) // 寫數據
{
delay_nus(20);
if(cd==0)
{
LCD_RS=1; //RS=1,寫顯示內容
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();
}
作者:
鄭漢松
時間:
2020-4-12 16:36
LCD寫命令模式,第一行是0x80+列位置,第二行是0xc0+列位置
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1