Serial begin

when I use this code on Arduino MEGA the proteus simulation is not running and I receive this error. when I delete the serial. begin the code is running. is there is any other simulation programs I can use?

"PC=0x00EE. [AVR USART 3] Writing to UDR3 while transmission is not enabled. Data will be ignored. [ARD1]"

#define trigPin 9
#define echoPin 10

long duration;
int distance;
void setup() {
  Serial.begin(9600);
  // put your setup code here, to run once:
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
Serial.print("Distance: ");
Serial.println(distance);
}

Does a simple "Hello World" print program work ? What happens if you try a Uno instead of a Mega ?

UKHeliBob: Does a simple "Hello World" print program work ? What happens if you try a Uno instead of a Mega ?

no, the simulation is refusing any serial line the Arduino UNO is working perfectly I think the problem is from the simulator maybe there is some problems in the design

So do you have real hardware or are you forced to use a simulator?

maybe tinkercad?

best regards Stefan