How to read and display from digital input

Hello,

I have Arduino Mega and I connected FM receiver to pin 19,
which is RX (receive information) in serial 1

If I want to read data from digital input pins on serial and see it in Serial Monitor, I write:

x = digitalRead (receiverPin);
Serial.println (x);

But for serial 1 I tried:

x = Serial1.read (receiverPin);
Serial.println (x);

no values appeared in the serial monitor, why and how to solve this?

But for serial 1 I tried:

x = Serial1.read (receiverPin);
Serial.println (x);

no values appeared in the serial monitor, why and how to solve this?

Seria1.read() expects no arguments or one argument that defines where to store the data. It returns either the data that is read from the serial buffer (when no arguments are supplied) OR it returns the number of bytes read.

If your device is actually sending serial data, and Serial1 is reading that data (because you have the output connected to the RX1 pin, then storing the data in receiverPin seems stupid, and printing the number of characters read is equally useless.

PaulS:
Seria1.read() expects no arguments or one argument that defines where to store the data. It returns either the data that is read from the serial buffer (when no arguments are supplied) OR it returns the number of bytes read.

If your device is actually sending serial data, and Serial1 is reading that data (because you have the output connected to the RX1 pin, then storing the data in receiverPin seems stupid, and printing the number of characters read is equally useless.

I want serial monitor to read what values that has reached my arduino

Check if the serial buffer is ready to be read (if there is data available) before you read. Use Serial1.available() . If this never returns a value greater than 0, no valid data is coming into the Rx pin.

void setup()
{
    Serial.begin(9600) // Set baud rate
    Serial1.begin(9600) // Set baud rate
}

void loop()
{
    while (Serial1.available())
        Serial.print(Serial1.read())
        
}

Regards,
Ray L.

I want serial monitor to read what values that has reached my arduino

Not even remotely possible. Where are those values coming from, and how do you expect an application on another computer to read them?