极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 13507|回复: 3

代码中1602A针脚该如何接在Arduino上?

[复制链接]
发表于 2016-11-27 20:51:21 | 显示全部楼层 |阅读模式
代码

#include <LiquidCrystal.h>  
LiquidCrystal lcd(12,11,5,4,3,2);
const int TrigPin = 9;
const int EchoPin = 8;
float distance;

void setup()
{
Serial.begin(9600);
pinMode(TrigPin, OUTPUT);
pinMode(EchoPin, INPUT);
Serial.println("Ultrasonic sensor:");
}

void loop()
{
digitalWrite(TrigPin, LOW);
delayMicroseconds(2);
digitalWrite(TrigPin, HIGH);
delayMicroseconds(10);
digitalWrite(TrigPin, LOW);
distance = pulseIn(EchoPin, HIGH) / 58.00;
lcd.setCursor(0,0);
lcd.print(distance);
lcd.print("cm");
lcd.println();
delay(700);
}  

这个代码中1602A该怎么接入Arduino中?
回复

使用道具 举报

发表于 2016-11-27 23:09:03 | 显示全部楼层
虽然我没有用过

LiquidCrystal lcd(12,11,5,4,3,2);
const int TrigPin = 9;
const int EchoPin = 8;

LiquidCrystal(uint8_t rs, uint8_t enable,
                uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);

不过从这里应该看得出引脚怎么接
回复 支持 反对

使用道具 举报

发表于 2016-11-28 09:18:18 | 显示全部楼层
/* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground   */
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
// LCD1602          RS  EN  D4 D5 D6 D7
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
回复 支持 反对

使用道具 举报

发表于 2016-11-29 22:15:32 来自手机 | 显示全部楼层
看一示例代码里头是怎么写的,然后进行调试。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-26 18:14 , Processed in 0.038931 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表