Blocks in the serial monitor

Hi, I have a problem that I can't figure out. I have an arduino uno with a hc-06 bluetooth module connected to the pins 0 and 1 (rx and tx). Rx--arduino Tx. Tx--arduino Rx. Gnd--Gnd. +5v--+5v
The function of my code is to receive Bt signals (in letters) from an app on my phone and print them the serial monitor. it has worked before but this time I tried it several times and the only result is some queer blocks in the serial monitor. Sometimes these blocks would stop when I sent the first signal from my phone, but it still didn't print the letter. Here is the code I am using.`

char val;
void setup() {
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  while (Serial.available()>0);
  {
  char val = Serial.read();    
  Serial.println(val);
  }
}

Can someone help me? Thanks.

To start with, Arduino Uno TX and RX are used also for the Serial Monitor, so you have a problem. Perhaps you misremember, and your HC05 module was attached to other pins on the Uno, and software Serial was used to talk to the HC05, while Serial was used to talk to Serial Monitor?

1 Like

You can't use 0 & 1 pins if you plan to talk with Serial monitor

Get rid of the semicolon.

Using hardware serial with the HC05 is fine. Input can only come from the phone, and output will be sent to both the phone and the monitor.

1 Like

Thank you very much! I am a beginner at programming and I was really stuck. I tried what you said and it worded perfectly. May God bless you and thanks again!

So the limitation for serial monitor in this case is, you can only use it for display, not input. Got it.

I think I understand. Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.