RFID and LCD on Mega

Hello everyone.

I’m trying to combine 2 different working projects into 1. Namely a RFID scanner on a Mega 2560 with a LCD to show some results out of the RFID.
Seperately they work but combined they don’t. I’ve been fidling around but can’t find the error yet. Not sure if it’s code so could anyone give it a look?

I’m also sending power to 8 different digital outs depending on the RFID tag. But thats working. So the RFID side works but the LCD is only lighting up and not showing anything.

Code:

* Components:
 *   Arduino Mega
 *   RFID-RC522
 *   LCD JHD 162A
 *   -----------------------------------------------------------------------------------------
 * RFID scanner layout used:
 *             MFRC522      Arduino
 *             Reader/PCD   Mega 
 * Signal      Pin          Pin
 * RST/Reset   RST          5  nu 6
 * SPI SS      SDA(SS)      53
 * SPI MOSI    MOSI         51
 * SPI MISO    MISO         50
 * SPI SCK     SCK          52
 * 
 * -----------------------------------------------------------------------------------------
 * LCD layout:
 * 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
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
*/

#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal.h>

#define RST_PIN         6          // Configurable, see typical pin layout above
#define SS_PIN          53        // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

// Configure LCD pins to arduino pins:
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;      
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

// Configure Output to robot on pins of Arduino board:
const int Pin1 = 31; // the number of pin1
const int Pin2 = 32; // the number of pin2
const int Pin3 = 33; // the number of pin3
const int Pin4 = 34; // the number of pin4
const int Pin5 = 35; // the number of pin5
const int Pin6 = 36; // the number of pin6
const int Pin7 = 37; // the number of pin7
const int Pin8 = 38; // the number of pin8

void setup() {
// RFID:
	Serial.begin(9600);		// Initialize serial communications with the PC
	while (!Serial);		// Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
	SPI.begin();			// Init SPI bus
	mfrc522.PCD_Init();		// Init MFRC522
	mfrc522.PCD_DumpVersionToSerial();	// Show details of PCD - MFRC522 Card Reader details
	Serial.println(F("Scan PICC to determin program action"));

// LCD:
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  // Print a message to the LCD.
  lcd.print("1234567890123456");

// COMM; set pins for output:
  pinMode(Pin1, OUTPUT);
  pinMode(Pin2, OUTPUT);
  pinMode(Pin3, OUTPUT);
  pinMode(Pin4, OUTPUT);
  pinMode(Pin5, OUTPUT);
  pinMode(Pin6, OUTPUT);
  pinMode(Pin7, OUTPUT);
  pinMode(Pin8, OUTPUT);
}

void loop() {
// 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();

// Compare scanned card to options:
  if (content.substring(1) == "4D 03 A0 59") //tag
    {
    Serial.println("Tag for pin 1");
    digitalWrite(Pin1, LOW);
    digitalWrite(Pin2, HIGH);
    digitalWrite(Pin3, LOW);
    digitalWrite(Pin4, LOW);
    digitalWrite(Pin5, LOW);
    digitalWrite(Pin6, LOW);
    digitalWrite(Pin7, LOW);
    digitalWrite(Pin8, LOW);
    Serial.println();
    delay(3000);
    }
  else if (content.substring(1) == "49 EF E8 AB") //card
    {
    Serial.println("Card Authorized access 3");
    digitalWrite(Pin1, LOW);
    digitalWrite(Pin2, LOW);
    digitalWrite(Pin3, HIGH);
    digitalWrite(Pin4, LOW);
    digitalWrite(Pin5, LOW);
    digitalWrite(Pin6, LOW);
    digitalWrite(Pin7, LOW);
    digitalWrite(Pin8, LOW);
    Serial.println();
    delay(3000);
    }
  
  else 
    {
    Serial.println("Tag unknown");
    digitalWrite(Pin1, LOW);
    digitalWrite(Pin2, LOW);
    digitalWrite(Pin3, LOW);
    digitalWrite(Pin4, LOW);
    digitalWrite(Pin5, LOW);
    digitalWrite(Pin6, LOW);
    digitalWrite(Pin7, LOW);
    digitalWrite(Pin8, LOW);
    delay(3000);
    }

// LCD
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

Ow, I just thought: I've tested the LCD on a uno not on a mega but the pin layout remained the same. So when I moved the wires to the mega and combined the code to what I've posted, it didn't work. Could the mega respond differently to code?

Could the mega respond differently to code?

No. But if the code says use SPI to do XXX, and you don't have the SPI device that is supposed to do XXX connected to the Mega's SPI pins, the code could fail to work.

So when I moved the wires to the mega and combined the code to what I've posted, it didn't work.

Something happened. It likely wasn't what you expected, but it isn't clear what actually happened or what you expected.