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);
}