Hi
I'm trying to use a master and slave setup for an RFID locking mechanism, but whenever I insert the SCL and SDA for the Master and Slave and the SCL and SDA for the screen, the screen just stops working, it remains powered on with white rectangles.
My code and setup are below..
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define SS_PIN 53
#define RST_PIN 5
#define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
int n = 1;
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.print("Approximate your card to the reader...");
Serial.println();
lcd.begin (16,2); // <<----- My LCD was 16x2
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home();
lcd.print("Hello Huuman");
delay(200);
lcd.clear();
lcd.home();
}
void loop() {
Wire.beginTransmission(8); // transmit to device #9
x++; // Increment x
if (x > 5) x = 0; // `reset x once it gets 6
delay(500);
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content = "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "9E 6E 64 55") //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized Access");
lcd.print("Authorized Access");
delay(2000);
lcd.clear();
lcd.print("Hello Huuman");
lcd.home();
if (lcd.print("Authorized Acess"))
{
Serial.println();
Wire.write(3);
Wire.endTransmission();
}
else {
Serial.println(" Access Denied");
lcd.print(" Access Denied");
delay(2000);
lcd.clear();
lcd.print("Hello Huuman");
lcd.home();
delay(300);
}
}
}
[Code/]
