Lcd1602连接Arduino UNO 与 Wemos D1接法与代码

LCD1602有16个引脚  使用1-6号与11-16号引脚

此处LCD1602:#1——#6   #11——#16

#1:负极

#2:正极

#3:1kΩ电阻调节对比度

#4:arduino7号引脚

#5:负极

#6:arduino6号引脚

#11:arduino5号引脚

#12:arduino4号引脚

#13:arduino3号引脚

#14:arduino2号引脚

#15:负极

#16:正极

(没错   GND确实有好多线被连到哈哈哈哈哈哈哈哈哈)

/*
  Wemos D1代码段
  LiquidCrystal Library - display() and noDisplay()

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD and uses the
 display() and noDisplay() functions to turn on and off
 the display.

 The circuit:
 * 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
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 modified 7 Nov 2016
 by Arturo Guadalupi

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = D7, en = D6, d4 = D5, d5 = D4, d6 = D3, d7 = D2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

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() {
  // Turn off the display:
  lcd.noDisplay();
  delay(500);
  // Turn on the display:
  lcd.display();
  delay(500);
}
/* Arduino UNO代码段  */
#include <LiquidCrystal.h>
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9

MFRC522 mfrc522(10, RST_PIN);   // 创建MFRC实例
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  pinMode(8,OUTPUT);
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("系统开启,请将你的卡片放置感应区...");

  
}

void loop() {
  String content= "";
  lcd.setCursor(0,0);
  lcd.print("Welcome!");
  lcd.print(content);
  // 寻找新卡
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //显示卡号 b6a5eebc 182165238188
  //Serial.print("UID tag :");
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     //Serial.println(mfrc522.uid.uidByte[i]);
     //Serial.print(mfrc522.uid.uidByte[i], HEX);
     content+=mfrc522.uid.uidByte[i];
  }
  if(content!="")
  {
      lcd.setCursor(0,0);
      lcd.print("Your ID:");
      lcd.setCursor(0,1);
      lcd.print(content);
      Serial.println(content);
      digitalWrite(8,HIGH);
      delay(300);
      digitalWrite(8,LOW);
      delay(2000);
      content= "";
      lcd.clear();
  }
  
}

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值