首页 > 编程知识 正文

1602a液晶屏怎么连线(a1602是第几代)

时间:2023-05-06 06:38:11 阅读:77220 作者:3044

直接连接到Arduino

2 .通过适配器板以I2C方式与Arduino连接

1 .直接连接到Arduino直接连接到Arduino的好处是不需要单独购买适配器板,但这将占用大量的Arduino io端口。 如果您的项目包含较少的外部传感器,则没有问题;但是,如果需要外部很多传感器和其他附件,则IO端口会变得很陡~

所需材料1x Arduino uno1x液晶屏16 x21 x 10k旋转变阻器1x穿孔板布线示意图

加载库文件在Arduino IDE 1.6.2或更高版本中,可以在“项目”-“加载库”-“管理库”中搜索和安装LiquidCrystal。 示例代码//includethelibrarycode : # includeliquidcrystal.h//initializethelibrarywithenumbersoftheinterfacepinsliquiqutal //printamessagetothelcd.LCD.print (' hello,world! (); }void loop () { //set the cursor to column 0,line1//} note : line1isthesecondrow,since counting begins with 0) 3360LCD.) //printthenumberofsecondssincereset : LCD.print (millis (/1000 ); }参考文献https://www.arduino.cc/en/reference/liquid crystal

2 .通过这种通过PCF8574t适配器板连接到Arduino的方式,可以大大节约Arduino的IO端口,前提是还必须购买PCF8574t适配器板。

所需材料1 xarduinouno1xlcd 16 x21 xpcf 8574 t中继板上的烙铁、焊锡、松香等布线,首先将中继板焊接在LCD显示屏上(

SCL -顶部端口SDA -第二个端口扫描I2C地址将以下代码复制到Arduino IDE并运行: 然后,通过选择“工具”—“串行监视器”并将右下角的波特率更改为115200,可以读取I2C地址,如下图所示。

//I2C扫描器//writtenbynickgammon//date :20 th April 2011 # include wire.hvoidsetup ((serial.begin ) ) 115200; //Leonardo : waitforserialporttoconnectwhile (! 序列(} serial.println ); serial.println (I2C scanner.scanning . '; 字节计数=0; Wire.begin (; for(byteI=8; i 120; I ) wire.begin传输(I; if(wire.endtransmission(==0) serial.print ) ' foundaddress: ' ); 序列. print (I,DEC ); serial.print (() ) ) )0x ); Serial.print(I,HEX ); Serial.println (' ); 出局; dlay(1; //maybe未连接? (/endofgoodresponse )/endofforloopserial.println (' done.' ); serial.print(found ); 序列. print (count,DEC ); serial.println ('设备(s ).'; } //end of setupvoid loop () }

将库文件下载到此处下载最新的新liquid crystal,然后手动将其添加到Arduino IDE中。 (ps:修改您的I2C地址,将liquid crystal _ I2C液晶屏(0x3F、2、1、0、4、5、6、7 )中的0x3F更改为您的真实地址)

示例代码/* demonstrationsketchforpcf 8574 ti2clcdbackpackuseslibraryfrom https://bit bucket.org/fmalpartida/new-liquid crystary downloadsgnugeneralpubliclicense,版本3 (GPL-3.0 )/# include wire.h # include LCD.h # includeliquidcrystal _ I2C///for 16x2lcdmodulelcd.setbacklightpin (3,POSITIVE; LCD.setbacklight(high ); } void loop () { lcd.home ); //set cursor to 0,0 LCD.print (' tronixlabs.com); 液晶屏. set cursor (0,1 ); //gotostartof2ndlinelcd.print (millis ) ); 延迟(1000; LCD.setbacklight(low; //backlightoffdelay(250; LCD.setbacklight(high ); //backlightonDelay(1000; }参考文献http://www.instructables.com/id/using-PCF 8574-backpacks-with-LCD-modules-and-ardui/allsteps

本文摘自http://www.Jian Shu.com/p/eee 98 f b5 e 68f

在此感谢作者的贡献。

转载于:https://www.cn blogs.com/sat innovation/p/8047240.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。