代码中1602A针脚该如何接在Arduino上?
代码#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中? 虽然我没有用过
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);
不过从这里应该看得出引脚怎么接 /* 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 RSEND4 D5 D6 D7
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
看一示例代码里头是怎么写的,然后进行调试。
页:
[1]