作为刚入门Arduino编程的你,要想掌握它的核心技术,就必须先掌握lcd1602模块的初始化。
LCD1602液晶显示模块,是一个显示16个字符,共两行的模块,通过简单的IO接口,就可以和你的工程连接起来。在实际应用中, 1602 显示模块涉及到的基本操作: 清屏、光标设置、光标显示、光标闪烁、字符展示、物理位置设置和自定义字符等。
下面是一个简单的lcd1602初始化示例(将本示例直接复制下来,粘贴到你的Arduino编辑器中即可):
// include the library code:#include // initialize the library with the numbers of the interface pinsLiquidCrystal lcd(12, 11, 5, 4, 3, 2);void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!");}void loop() { // put your main code here, to run repeatedly: lcd.setCursor(0, 1); lcd.print(millis() / 1000);}
不难看出,上述代码中先使用 include
细心的小伙伴可能会发现,在 loop 中的 lcd.setCursor(0, 1) 和 lcd.print(millis() / 1000) 分别指定了行和列,从而显示了流逝的时间。上述示例是做为基础的示例,在实际应用中,可以根据需求对其进行更加高级的操作。
当然,掌握lcd1602的初始化只是你入门Arduino编程的一个开端。