Lcd.clear() does not work

Hi there,
So, I have a project called Smart Hospital. I have a NFC-reader which does work, and a lcd-screen. But thats the problem, my lcd-screen does not clear. I have used lcd.clear() and lcd.setCursor(0,0), but the lcd still won't clear. Here is my code:

#include <LiquidCrystal.h>
#include <MFRC522.h>
int lamp = 7;
int seconds = 0;

LiquidCrystal lcd(1, 6, 5, 4, 3, 2);
MFRC522 mfrc522(10,9);
void setup()
{
  pinMode(lamp, OUTPUT);
  lcd.begin(16, 2);
  delay(100);
  lcd.clear();

  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
}

bool detectNFC(){
  if(mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()){
    Serial.println("NFC-tag gedetecteerd");
    mfrc522.PICC_HaltA();
    return true;
  }else{
    return false;
  }
}

void loop()
{
 if(detectNFC()){
    digitalWrite(lamp, HIGH);
    lcd.print("Nat maken");
    delay(10000);
    lcd.clear();
    delay(100);
    digitalWrite(lamp, LOW);
    lcd.print("Shampoo");
    delay(5000);
    lcd.clear();
    digitalWrite(lamp, HIGH);
    lcd.print("Haren afspoelen");
    delay(10000);
    lcd.clear();
    delay(100);
    digitalWrite(lamp, LOW);
    lcd.print("Douchegel");
    delay(7500);
    lcd.clear();
    delay(100);
    digitalWrite(lamp, HIGH);
    lcd.print("Lichaam");
    lcd.setCursor(0,1);
    lcd.print("afspoelen");
    delay(15000);
    lcd.clear();
    delay(100);
    digitalWrite(lamp, LOW);
 }
}

do not use pin 1 for display

Thank you, it works now!!

1 Like

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