NOT getting how to use SERIAL PORT as a passkey INPUT

Hello World ,
I am recently facing a problem in a program in which I have to take input from the user using the Serial port but i am not able to process the input properly

String pass=0;
void setup()
void loop()
    Serial.println("Correct passkey");
   else if(pass!="1234") 
   Serial.println("Incorrect passkey");
}; reads a single character so what is read will never equal "1234"
Have a look at the Serial.readStringUntil() function

Even better, look at Serial input basics - updated and don't use Strings at all

Simple serial echo test code that captures characters and sends them back to the serial monitor.

//zoomkat 6-29-14 Simple serial echo test
//type or paste text in serial monitor and send

String readString;

void setup() {
  Serial.println("Simple serial echo test"); // so I can keep track of what is loaded

void loop() {

  while (Serial.available()) {
    char c =;  //gets one byte from serial buffer
    readString += c; //makes the String readString
    delay(3);  //slow looping to allow buffer to fill with next character

  if (readString.length() > 0) {
    Serial.println(readString);  //so you can see the captured String
    readString = "";