Bird
Raised Fist0
Arduinoprogramming~20 mins

Bluetooth with HC-05/HC-06 module in Arduino - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Bluetooth Mastery with HC-05/HC-06
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output on Serial Monitor?
Consider this Arduino code using HC-05 Bluetooth module. What will be printed on the Serial Monitor when the module receives the character 'A' from a paired device?
Arduino
void setup() {
  Serial.begin(9600); // Serial Monitor
  Serial1.begin(9600); // HC-05 module
}

void loop() {
  if (Serial1.available()) {
    char c = Serial1.read();
    if (c == 'A') {
      Serial.println("Received A");
    } else {
      Serial.println("Other char");
    }
  }
}
AReceived A
BOther char
CNo output
DCompilation error
Attempts:
2 left
💡 Hint
Check what happens when Serial1 reads 'A'.
❓ Predict Output
intermediate
2:00remaining
What will be the output of this code snippet?
This Arduino sketch reads data from HC-06 module and echoes it back. What will be printed on Serial Monitor if the paired device sends 'Hello'?
Arduino
void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  while (Serial1.available()) {
    char c = Serial1.read();
    Serial.print(c);
    Serial1.print(c);
  }
}
ANo output
BolleH
CHello
DCompilation error
Attempts:
2 left
💡 Hint
Look at how characters are read and printed.
❓ Predict Output
advanced
2:00remaining
What error does this code produce?
This code tries to initialize HC-05 module but has a mistake. What error will occur when compiling?
Arduino
void setup() {
  Serial.begin(9600);
  Serial1.begin(38400); // Missing semicolon fixed
}

void loop() {}
ASyntaxError: missing semicolon
BTypeError: wrong baud rate
CNo error, runs fine
DRuntime error: Serial1 not found
Attempts:
2 left
💡 Hint
Check punctuation at the end of lines.
🧠 Conceptual
advanced
1:30remaining
Which statement about HC-05 and HC-06 modules is correct?
Choose the correct statement about HC-05 and HC-06 Bluetooth modules.
AHC-06 can act as master or slave; HC-05 only as slave
BBoth HC-05 and HC-06 can only act as master
CBoth HC-05 and HC-06 can only act as slave
DHC-05 can act as master or slave; HC-06 only as slave
Attempts:
2 left
💡 Hint
Think about flexibility of module roles.
🚀 Application
expert
2:30remaining
How many bytes will be stored in buffer after this code runs?
Given this Arduino code snippet reading from HC-05, how many bytes will be stored in the buffer array after receiving the string 'BT123'?
Arduino
char buffer[10];
int index = 0;

void loop() {
  while (Serial1.available()) {
    char c = Serial1.read();
    if (c == '\n') break;
    buffer[index++] = c;
  }
}
A6
B5
C4
D0
Attempts:
2 left
💡 Hint
Count characters before newline.

Practice

(1/5)
1. What is the main purpose of using an HC-05 or HC-06 Bluetooth module with an Arduino?
easy
A. To enable wireless serial communication between Arduino and other Bluetooth devices
B. To increase the Arduino's processing speed
C. To provide power supply to the Arduino
D. To connect Arduino to the internet via Wi-Fi

Solution

  1. Step 1: Understand the function of HC-05/HC-06 modules

    These modules are designed to allow wireless serial communication using Bluetooth technology.
  2. Step 2: Compare options with module purpose

    Only To enable wireless serial communication between Arduino and other Bluetooth devices correctly describes enabling wireless serial communication; others describe unrelated functions.
  3. Final Answer:

    To enable wireless serial communication between Arduino and other Bluetooth devices -> Option A
  4. Quick Check:

    HC-05/HC-06 = Wireless serial communication [OK]
Hint: HC-05/HC-06 = Bluetooth serial communication module [OK]
Common Mistakes:
  • Confusing Bluetooth with Wi-Fi connectivity
  • Thinking it powers the Arduino
  • Assuming it speeds up Arduino processing
2. Which of the following is the correct way to create a SoftwareSerial object for HC-05 on pins 10 (RX) and 11 (TX)?
easy
A. SoftwareSerial BT(11, 10);
B. SoftwareSerial BT(10, 11);
C. SoftwareSerial BT(9, 8);
D. SoftwareSerial BT(0, 1);

Solution

  1. Step 1: Recall SoftwareSerial constructor syntax

    The constructor is SoftwareSerial(rxPin, txPin), so RX is first, TX second.
  2. Step 2: Match pins to constructor

    Given RX=10 and TX=11, the correct call is SoftwareSerial BT(10, 11);
  3. Final Answer:

    SoftwareSerial BT(10, 11); -> Option B
  4. Quick Check:

    SoftwareSerial(rx, tx) = SoftwareSerial(10, 11) [OK]
Hint: SoftwareSerial(rxPin, txPin) order matters [OK]
Common Mistakes:
  • Swapping RX and TX pins
  • Using default hardware serial pins (0,1) for SoftwareSerial
  • Choosing pins not supported by SoftwareSerial
3. Given the code snippet below, what will be printed on the Serial Monitor if the HC-05 sends the string "Hello"?
SoftwareSerial BT(10, 11);
void setup() {
  Serial.begin(9600);
  BT.begin(9600);
}
void loop() {
  if (BT.available()) {
    char c = BT.read();
    Serial.print(c);
  }
}
medium
A. No output
B. Random characters
C. Error: BT not initialized
D. Hello

Solution

  1. Step 1: Understand data flow in code

    The code reads characters from Bluetooth (BT) and prints them to Serial Monitor.
  2. Step 2: Analyze input and output

    If HC-05 sends "Hello", BT.read() reads each character and Serial.print outputs them, so "Hello" appears.
  3. Final Answer:

    Hello -> Option D
  4. Quick Check:

    BT.read() + Serial.print = "Hello" [OK]
Hint: BT.read() prints incoming Bluetooth data directly [OK]
Common Mistakes:
  • Assuming no output without Serial.println
  • Forgetting to call BT.begin()
  • Confusing BT with Serial hardware pins
4. Identify the error in this Arduino code snippet for HC-05 communication:
SoftwareSerial BT(10, 11);
void setup() {
  Serial.begin(9600);
  BT.begin(115200);
}
void loop() {
  if (BT.available()) {
    Serial.write(BT.read());
  }
}
Assuming the HC-05 module is set to 9600 baud.
medium
A. Serial.begin is missing
B. SoftwareSerial pins are incorrect
C. BT.begin baud rate does not match HC-05 baud rate
D. BT.read() should be inside setup()

Solution

  1. Step 1: Check baud rate consistency

    HC-05 default baud is 9600, but BT.begin uses 115200, causing communication failure.
  2. Step 2: Verify other code parts

    SoftwareSerial pins and Serial.begin are correct; BT.read() is correctly placed in loop.
  3. Final Answer:

    BT.begin baud rate does not match HC-05 baud rate -> Option C
  4. Quick Check:

    Baud rates must match for communication [OK]
Hint: Match BT.begin baud with HC-05 baud rate [OK]
Common Mistakes:
  • Using different baud rates between Arduino and HC-05
  • Placing BT.read() in setup() instead of loop()
  • Confusing Serial and SoftwareSerial pins
5. You want to send the string "LED ON" from your phone to Arduino via HC-05. The Arduino should turn on an LED connected to pin 13 when it receives this exact string. Which code snippet correctly implements this behavior?
hard
A. SoftwareSerial BT(10, 11); String input = ""; void setup() { pinMode(13, OUTPUT); Serial.begin(9600); BT.begin(9600); } void loop() { while (BT.available()) { char c = BT.read(); input += c; } if (input == "LED ON") { digitalWrite(13, HIGH); input = ""; } }
B. SoftwareSerial BT(10, 11); void setup() { pinMode(13, OUTPUT); Serial.begin(9600); BT.begin(9600); } void loop() { if (BT.read() == 'LED ON') { digitalWrite(13, HIGH); } }
C. SoftwareSerial BT(10, 11); void setup() { pinMode(13, OUTPUT); Serial.begin(9600); BT.begin(9600); } void loop() { if (BT.available()) { digitalWrite(13, HIGH); } }
D. SoftwareSerial BT(10, 11); String input = ""; void setup() { pinMode(13, OUTPUT); Serial.begin(9600); BT.begin(9600); } void loop() { if (BT.available()) { input = BT.read(); } if (input == "LED ON") { digitalWrite(13, HIGH); } }

Solution

  1. Step 1: Collect full string from Bluetooth input

    The correct code declares a global String input = ""; and uses while (BT.available()) { char c = BT.read(); input += c; } to accumulate all available characters into the string.
  2. Step 2: Compare the full input string and control LED

    After accumulating, if (input == "LED ON") { digitalWrite(13, HIGH); input = ""; } turns on the LED and clears the input for next message.
  3. Step 3: Analyze other options

    One option incorrectly compares a single BT.read() char to 'LED ON'; another turns on the LED on if (BT.available()) without checking content; the last captures only a single char per loop with input = BT.read().
  4. Final Answer:

    The code snippet that accumulates characters into a String using while(BT.available()) -> Option A
  5. Quick Check:

    Read full input string before comparing [OK]
Hint: Build full string from BT.read() before comparing [OK]
Common Mistakes:
  • Comparing single char to full string
  • Not accumulating all characters before checking
  • Turning LED on without input check
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard