美文网首页
1602a 四位接线法

1602a 四位接线法

作者: 第四维_2004 | 来源:发表于2018-04-12 14:10 被阅读0次
四位接线法代码

/**

* VSS GND

* VDD 5V

* V0  GND

* RS  12

* RW  11

* E  10

* D4  9

* D5  8

* D6  7

* D7  6

* A  V5

* K  GND

* from http://surenpi.com

* created 2015/3/23

*/int LCD1602_RS=12;int LCD1602_RW=11;int LCD1602_EN=10;int DB[] = { 6, 7, 8, 9};char str1[]="Welcome to";char str2[]="surenpi";char str3[]="find me";char str4[]="surenpi.com";

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 cleanScreen(int delayTime = 50){

  LCD_Command_Write(0x01);

  delay(delayTime);

}

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, int delayTime = 50){

  LCD_SET_XY(x, y);    //设置地址 

  int i = 0;

  while(*s && ++i <= 16)            //写字符串  {

    LCD_Data_Write(*s); 

    s++;

  }

  delay(delayTime);

  if(*s)

  {

    cleanScreen();

    LCD_Write_String(x, y, s, delayTime);

  }

}

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){

  cleanScreen();

  LCD_Write_String(3,0,str1);//第1行,第4个地址起  LCD_Write_String(0,1,str2, 3000);//第2行,第2个地址起 

  cleanScreen();

  LCD_Write_String(0,0,str3);

  LCD_Write_String(0,1,str4, 3000);

}

米思奇

相关文章

  • 1602a 四位接线法

    /** * VSS GND * VDD 5V * V0 GND * RS 12 * RW 11 * E 10 *...

  • 树莓派与LCD屏1602a

    1. 1602a LCD屏 接线端子表: 序号LCD屏 16PIN树莓派 40PIN 物理序号备注1VSS06GN...

  • 电加热管有哪些接线方式?

    电加热管的接线方式主要有四种:串联、并联、三角形接线法(角接)、Y形接线法(星型接线法)。 串联:单根管子的电压相...

  • 吴氏四位分节数据表示法

    吴氏四位分节法是指在文字表达数据时每四位间用符号“-”或“`”进行分隔。如123456789.00用1-2345-...

  • 接线

    请提供下图两接口线:一一对应连接

  • 配电柜的线怎么区分

    线路连接线号的标法每个单位都不同,介绍常用的几种: 1、线号头尾一致,这种标法一般用于低压柜。 2、头尾一不致,为...

  • 交直流数字高压表操作分享

    交直流数字高压表操作分享 1.正确接线 按图所示接线方法正确接线。高压输入接均压球顶端接线柱,接地柱通过仪器配套接...

  • 2017年11月7日学习总结

    今天老师讲了一位数码管和四位数码管的显示和程序,因为上午老师有事讲的不多,让我们根据课件进行接线和编程,根据课件上...

  • 百法22课

    本课主要是讲心不相应行法的后四位法以及无为法六种和导师对百法的归纳与总结三部分组成。 方是指空间方位、处所,也具有...

  • 接线端子的五大连接技术!——AMPLUM

    接线端子排是电气设备中,用来连接线路的一种电器元器件。接线端子排每排接线端点数的数量是不同的,而且还分为不同系列。...

网友评论

      本文标题:1602a 四位接线法

      本文链接:https://www.haomeiwen.com/subject/pxcdtftx.html