Arduino LCD showing unknown character when programmed with other component

the LCD works correctly when used alone, but begins to show strange character when other components are connected to the arduino. for example. when the keypad button and lcd are connected, and the program is written for the LCD to display after a button press, the LCD display unknown character instead.

Please post the full sketch that exhibits the problem and a schematic of your project. It is impossible to see exactly how things are connected from your 'photo

Botton pressing messing with the things! That the code posted does not show any software debouncing and the photo posted does not show any hardware debouncing of switches, I'd guess that line 258 does not contain switch debounce code.

What do you mean full sketch please. do you want me to explain the project and post the code I wrote right?

let me explain the project. the aim of the project is create like a mini vending machine in which when the card is tapped on a RFID, it recognised the card and makes a motor to move 360 degree to push out an item from a box.
For this project, I am making use of, LCD , matrix keypad, a continuous servo motor and and RFID.
The code was written such that, the LCD will display, "pick a number", you press any number on the keypad
Then, it display tap your card. after which you swipe the card on the RFID.
Th Screen then show, "card authorised" which in turn makes the servo motor to rotate 360 degree.

it all worked when the serial monitor was use in place of the LCD, but anytime the lcd.print is used, the LCD display unknown character instead .

Yes, attach the code so that the location of the error is clarified. Is it a software error or a line in the hardware?

@UKHeliBob

#include <LiquidCrystal.h>
#include <Keypad.h>
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
Servo myservo;


// LCD pins
int RS = 7, E = 8, D4 = 0, D5 = 1, D6 = 2, D7 = 3;
LiquidCrystal lcd(RS, E, D4, D5, D6, D7);


#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

const byte ROWS = 4; //four rows
const byte COLS = 2; //two columns


//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] =
{
  {'1', 'A'},
  {'4', 'B'},
  {'7', 'C'},
  {'*', 'D'}
};
byte rowPins[ROWS] = {A5, A4, A2, A1}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A0, A3}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
bool count = true;
bool getNumber = false;
bool condition = true;
 bool access = true;
int Motor = 5;


void setup()
{
  lcd.begin (16, 2);
  lcd.print("goal");
  Serial.begin(9600);
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  pinMode(Motor, OUTPUT);
   myservo.attach(5);
  myservo.write(90);// move servos to center position -> 90°\
  
}

void loop()
{
  if (count == true)
  {
    Serial.println(" pick a number ");
    count = false;
  }

  char options;
  while (getNumber == false)
  {
    char customKey = customKeypad.getKey();
    if (customKey)
    {
      Serial.println(customKey);
      options = customKey;
      getNumber = true;
    }
  }
  if (getNumber == true && condition == true)
  {
    Serial.print("Ïnsert Card");
    condition = false;
  }

  // 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) == "B7 B8 7B 5A") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    Serial.println();
    delay(2000);
    while (access == true)
    {
        myservo.write(0);// move servos to turn 360
  delay(500);

  myservo.write(90);// move servos to center position
  delay(500);
      access = false;
    }
  }

  else   {
    Serial.println(" Access denied");
    delay(3000);
  }
 
}


this is the code when serial monitor is used `Preformatted text`

What part of the full sketch THAT EXHIBITS THE PROBLEM are you having difficulty understanding?

A photograph while handy is not a schematic.

You only need one of these.

I mean what I say. Too often users will post a snippet of code that they think is causing a problem only for the problem to be elsewhere

Indeed, there are many screen problems because there are several parties to it
1- First, make sure that all the sides of the bread board are intact, because this problem happened to me before the bread board had unconnected sides.
2- Make sure that the variable resistance connection is correct
3- Make sure that you are using the printing on it correctly through the places where it is printed
4- If the print is working in a serial monitor, make sure that the screen is well soldered
5- Test the screen with one component, for example, a temperature and humidity sensor, and if it works well
There is a problem with the code
best of luck

You appear to be using pins zero and one for the lcd, but those are used by the serial port.

That would no doubt explain:

Just by the way, remove the connection between the contrast potentiometer and 5 V. This is a long-standing error mindlessly copied from one design to the next. If using a 10k potentiometer (the other part of the error), connect both ends to ground. You will find it makes setting the contrast much easier.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.