Problem with Serial communications

I have been trying to write a program that uses the serial port to write "Hello" and receive "Hello" for over a week. I have not succeeded so far. I have looked at the various examples on the internet but none of them work. I tried to use pins 0 and 1, I tried to use pins 10 and 11 but no positive results. There is a complete program on the net that sends a message and receives the same message. With my program I only receive characters: 46, 115, 123, 32 etc.

Split from an unrelated topic
Please do not hijack topics

More details needed such as where you are expecting to see the messages, how they are entered and which Arduino board you are using. Please post your best effort sketch, even if it does not work

if those are ASCII code, you are receiving something that says ".s{ "

Do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).

Have a read through the Serial Input Basics tutorial right here in these forums.

using the serial monitor in the arduino IDE or with another arduino (while connected to the PC)?

I want to use Arduino to send and receive a "Hello" message via serial using pins 0 and 1 or other pins that could be used to transmit serial data. It is possible to have a simple example of a complete and working program. So far I have not found any examples on the internet. I want to use the serial monitor to finally see "Hello" broadcast and "Hello" reception. I hope to explain my problem as soon as I can. Best regards and Merry Christmas Pierluigi

I would suggest to study Serial Input Basics

Thanks in advance and merry Christmas. Pierluigi

This is my sketch:

#include <SoftwareSerial.h>

SoftwareSerial mySerial (0,1);//RX e TX

//I connect pin 0 with pin 1

int val2=0;

int giro=0;

void setup() {

pinMode(0, INPUT);

pinMode(1, OUTPUT);

mySerial.begin(9600);

Serial.begin(9600);

}

void loop() {

if (mySerial.available( ) > 0) {

val2 = mySerial.read( ); // read the serial port

Serial.print("Receive......: ");

Serial.println(val2);

}

delay (1000);

mySerial.write(giro);

Serial.print("Sent.......");Serial.println(giro);

delay(1000);

giro++;

Serial.print("Number turns......................");Serial.println(giro);

}

And this is the result:

Sent.......10

Number turns......................11

Receive......: 46

Sent.......11

Number turns......................12

Receive......: 46

Sent.......12

Number turns......................13

Receive......: 49

Sent.......13

Number turns......................14

Receive......: 13

Sent.......14

Number turns......................15

Receive......: 10

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Here is a sketch that sends "Hello" to Serial Monitor every ten seconds. It will display whatever it receives from Serial Monitor and reports whether it was "Hello" to not.

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  // Report whatever is received.
  if (Serial.available())
  {
    String input = Serial.readString();
    Serial.print("Received: \"");
    Serial.print(input);
    Serial.println("\"");
    if (input == "Hello")
      Serial.println("That was \"Hello\"");
    else
      Serial.println("That was NOT \"Hello\"");
    Serial.println();
  }

  // Send "Hello" every ten seconds
  static unsigned long lastTimeSent = 0;
  if (millis() - lastTimeSent >= 10000)
  {
    lastTimeSent += 10000;
    Serial.println("Hello");
  }
}