久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5107|回復: 4
打印 上一主題 下一主題
收起左側

基于Arduino的LCD1602顯示實驗

[復制鏈接]
跳轉到指定樓層
樓主
int LCD1602_RS=12;   
int LCD1602_RW=11;   
int LCD1602_EN=10;   
int DB[] = { 6, 7, 8, 9};
char str1[]="Welcome to";
char str2[]="geek-workshop";
char str3[]="this is the";
char str4[]="4-bit interface";

void LCD_Command_Write(int command)
{
int i,temp;
digitalWrite( LCD1602_RS,LOW);
digitalWrite( LCD1602_RW,LOW);
digitalWrite( LCD1602_EN,LOW);

temp=command & 0xf0;
for (i=DB[0]; i <= 9; i++)
{
   digitalWrite(i,temp & 0x80);
   temp <<= 1;
}

digitalWrite( LCD1602_EN,HIGH);
delayMicroseconds(1);
digitalWrite( LCD1602_EN,LOW);

temp=(command & 0x0f)<<4;
for (i=DB[0]; i <= 9; i++)
{
   digitalWrite(i,temp & 0x80);
   temp <<= 1;
}

digitalWrite( LCD1602_EN,HIGH);
delayMicroseconds(1);
digitalWrite( LCD1602_EN,LOW);
}

void LCD_Data_Write(int dat)
{
int i=0,temp;
digitalWrite( LCD1602_RS,HIGH);
digitalWrite( LCD1602_RW,LOW);
digitalWrite( LCD1602_EN,LOW);

temp=dat & 0xf0;
for (i=DB[0]; i <= 9; i++)
{
   digitalWrite(i,temp & 0x80);
   temp <<= 1;
}

digitalWrite( LCD1602_EN,HIGH);
delayMicroseconds(1);
digitalWrite( LCD1602_EN,LOW);

temp=(dat & 0x0f)<<4;
for (i=DB[0]; i <= 9; i++)
{
   digitalWrite(i,temp & 0x80);
   temp <<= 1;
}

digitalWrite( LCD1602_EN,HIGH);
delayMicroseconds(1);
digitalWrite( LCD1602_EN,LOW);
}

void LCD_SET_XY( int x, int y )
{
  int address;
  if (y ==0)    address = 0x80 + x;
  else          address = 0xC0 + x;
  LCD_Command_Write(address);
}

void LCD_Write_Char( int x,int y,int dat)
{
  LCD_SET_XY( x, y );
  LCD_Data_Write(dat);
}

void LCD_Write_String(int X,int Y,char *s)
{
    LCD_SET_XY( X, Y );    //設置地址
    while (*s)             //寫字符串
    {
      LCD_Data_Write(*s);   
      s ++;
    }
}

void setup (void)
{
  int i = 0;
  for (i=6; i <= 12; i++)
   {
     pinMode(i,OUTPUT);
   }
  delay(100);
  LCD_Command_Write(0x28);//4線 2行 5x7
  delay(50);
  LCD_Command_Write(0x06);
  delay(50);
  LCD_Command_Write(0x0c);
  delay(50);
  LCD_Command_Write(0x80);
  delay(50);
  LCD_Command_Write(0x01);
  delay(50);

}

void loop (void)
{
   LCD_Command_Write(0x01);
   delay(50);
   LCD_Write_String(3,0,str1);//第1行,第4個地址起
   delay(50);
   LCD_Write_String(1,1,str2);//第2行,第2個地址起
   delay(5000);
   LCD_Command_Write(0x01);
   delay(50);
   LCD_Write_String(0,0,str3);
   delay(50);
   LCD_Write_String(0,1,str4);
   delay(5000);

}

_1602.rar

860 Bytes, 下載次數: 18, 下載積分: 黑幣 -5

評分

參與人數 1黑幣 +10 收起 理由
木木123 + 10 贊一個!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:221607 發表于 2017-7-22 15:36 | 只看該作者
樓主不上個接線圖嗎
回復

使用道具 舉報

板凳
ID:110456 發表于 2017-7-24 21:29 | 只看該作者
接線圖在附件中

1602接線圖1.jpg (141.83 KB, 下載次數: 217)

1602接線圖1.jpg

1602接線圖02.jpg (174.75 KB, 下載次數: 208)

1602接線圖02.jpg
回復

使用道具 舉報

地板
ID:230261 發表于 2017-8-31 17:52 | 只看該作者
好東西,學習一下
回復

使用道具 舉報

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

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 天天操天天射综合 | 欧美日韩福利视频 | 成人免费视频网站 | 欧美aⅴ | 99精品国产一区二区三区 | 国产一区二区在线免费观看 | 欧美人人 | 国产一区二区在线免费播放 | 国产精品美女久久久久久免费 | 日韩无 | 九九久久久 | 国产精品一区二区三区在线 | 日本一区二区三区免费观看 | 欧美成人精品激情在线观看 | 亚洲精品久久久久久一区二区 | 成人av播放 | 免费在线视频a | 日本天堂视频在线观看 | 欧美xxxx黑人又粗又长 | 欧美在线视频一区二区 | 激情一区二区三区 | 国产精品美女www爽爽爽 | 国产精品免费大片 | 拍真实国产伦偷精品 | 亚洲国产欧美国产综合一区 | 久久国产视频网站 | 久久久久久国产精品免费免费 | 男女羞羞视频在线观看 | www在线视频| 亚州精品天堂中文字幕 | 免费人成激情视频在线观看冫 | 资源首页二三区 | 国产精品二区三区在线观看 | 久久综合伊人 | 精品国产欧美一区二区 | 四虎影院新网址 | 精品国产乱码久久久久久图片 | 色黄爽| av黄色免费 | 亚洲免费人成在线视频观看 | 99在线精品视频 |