UART

hi guys I have an HCSR04 on Arduino Uno and LCD 16x2 on atmega32 I want to send the ultrasonic data from the Arduino to the LCD on atmega I used UART but the Arduino send only the first reading then the other readings are 0
this is the Arduino code

#define trigPin2 4
#define echoPin2 5

long duration, distance, RightSensor;
char RightSensor_str[10];
void setup()
{
  Serial.begin (9600);

  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);

}

void loop() {

  SonarSensor(trigPin2, echoPin2);
  RightSensor = distance;
  itoa(RightSensor, RightSensor_str, 10);
  Serial.write(RightSensor_str);
  Serial.write('#');
  Serial.print(RightSensor);
  Serial.print(" - ");

}

void SonarSensor(int trigPin, int echoPin)
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;

}

How many characters are you sending each time you send data to the serial port?
At 9600 baud how long does it take for the serial port to transmit them?
How long does it take loop to loop?

solved !

I removed Serial.print from the code and it worked XD I thought that Serial.print is only working for the monitor

I ran your sketch, unchanged, on my Arduino UNO and it produces distance values that change with distance. Perhaps you have a bad wire.