Random messages in serial monitor

Hi, I am trying to see analog values of my infrared sensor in the serial monitor. However, instead of printing out numerical values, I get many random characters.

»»ã-{ø½ÿ³æÏZØK§¾Ï¼ú×%?ÿòÞuß]èìµÊ|ÿ]??=­»Î.ßI?ÌwW×?Îý8?èßï|7×ÿ×N½>þúGÌÀÿ$×C¾±ýN]ýÏöÿz]­o?g?òá}w?÷w?ÖzÿÏÿϾڒöWñí7ïÖ÷ÆÝ[Ë^ÉþÞïÏ~ÌÕ?¶îº*û½vöíKûÜ÷2:ÚÊ^Çõ±µü/¯À˧?ëÝo?÷櫯oò¿M<¿îþ¼ß÷òö®íîG??Â_¹{?îîù_³»Ù~?ãÜ?±?ýíet®kì?ýÔ3ZR>®ÜgÄMViìßû]+Zn?Têþï­7÷Í?¿?¯Ý¹s/[¼Ù»±ýÜìÏq³j:×·m#7ÅßÞ?S«ÿ®Èþsê½íëèåÏe?¶Øå¡Ü¿lï_ÿý¤÷óþÒ?_åõíüw¡¾<kÝGµ/Boäþ???|~ãRÿýsß-fßmKù7ýs?¾?püÞ}Ý?{ßy_v÷¯>»æù?Á×Ñúó?Îü¿??_ÿòóö^=gå»ÿûÖ’nÉþt^î?oßô,[ø¾^Ü?ù²önÝ¥ïW;·õo¿Æ·\¬s¤úÿÛÝ?¡ÿÅèÞÉïÑùûWÅó&Oödþ?~æOÙå?o
q³j:×·m#7ÅßÞ?S«ÿ®Èþsê½íëèåÏe?¶Øå¡Ü¿lï_ÿý¤÷óþÒ?_åõíüw¡¾<kÝGµ/Boäþ???|~ãRÿýsß-fßmKù7ýs?¾?püÞ}Ý?{ßy_v÷¯>»æù?Á×Ñúó?Îü¿??_ÿòóö^=gå»ÿûÖ’nÉþt^î?oßô,[ø¾^Ü?ù²önÝ¥ïW;·õo¿Æ·\¬s¤úÿÛÝ?¡ÿÅèÞÉïÑùûWÅó&Oödþ

Why does that happen and how can I fix it? Also, does this happen as a result of my code or the sensor?

int irReceiverRight = A5;
int irReceiverLeft = A6;

void setup(){
  Serial.begin (9600);
  pinMode (irReceiverRight, INPUT);
  analogWrite (irReceiverRight, 375);
  pinMode (irReceiverRight, INPUT);
  analogWrite (irReceiverLeft, 375);
  pinMode (12, OUTPUT);
  pinMode (9, OUTPUT);
  pinMode (13, OUTPUT);
  pinMode (8, OUTPUT);
}

void loop(){
  int receiverRight = analogRead (irReceiverRight);
  int receiverLeft = analogRead (irReceiverLeft);
  
  Serial.println(receiverRight + "" + receiverLeft);
  
  if((receiverRight >= 375) && (receiverLeft < 415))
   driveForward();
  else if(receiverRight >= 415 && receiverLeft < 415 && receiverLeft >= 375)
  {
    stopMotor();    
    driveBackward(); 
    stopMotor();
    turnLeft();
  }else if (receiverLeft >= 415 && receiverLeft >= 375 && receiverLeft < 415)
  {
    stopMotor();
    driveBackward();
    stopMotor();
    turnRight();
  }else //it both sensors pick up a signal, motor 1 stops and turns ccw
  {
    stopMotor();
    driveBackward();
    stopMotor();
    for (int x = 0; x <= 50; x++)
      turnRight();
  }
}

void driveForward()
{
  digitalWrite (12, HIGH);
  digitalWrite (9, LOW);
  analogWrite (3, 123);
  
  delay (1000);
}

void driveBackward()
{
  digitalWrite (12, LOW);
  digitalWrite (9, LOW);
  analogWrite (3, 123);
  
  delay (1000);
}

void stopMotor()
{
  digitalWrite (12, HIGH);
  digitalWrite (9, HIGH);
  analogWrite (3, 0);
  
  delay (1000);
}

void turnLeft()
{
  digitalWrite (13, HIGH);
  digitalWrite (8, LOW);
  analogWrite (11, 200);
  
  delay (500);
  
  digitalWrite (8, HIGH);
  
  delay (500);
  
  driveForward();
  
  digitalWrite (13, LOW);
  digitalWrite (9, LOW);
  analogWrite (11, 200);
  
  delay (500);
  
  digitalWrite (8, HIGH);
}

void turnRight()
{
  digitalWrite (13, LOW);
  digitalWrite (8, LOW);
  analogWrite (11, 200);
  
  delay (500);
  
  digitalWrite (8, HIGH);
  
  delay (500);
  
  driveForward();
  
  digitalWrite (13, HIGH);
  digitalWrite (9, LOW);
  analogWrite (11, 200);
  
  delay (500);
  
  digitalWrite (8, HIGH);
}

This is very creative, but it's not your grand-daddy's C:

  Serial.println(receiverRight + "" + receiverLeft);

Try printing the ints separately with a blank between them.

-br

Have you checked that the serial monitor is on the same speed. Check the bottom right hand corner of it.

Yes I have, it is on 9600 baud.

So try it with a simple bellow world code to test your wiring.

It prints the "hello world" but also prints the random characters from the previous statement.

aac353: It prints the "hello world" but also prints the random characters from the previous statement.

Then look at reply #1