Bird
0
0
Arduinoprogramming~10 mins

Why communication protocols matter in Arduino - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start serial communication at 9600 baud rate.

Arduino
void setup() {
  Serial.begin([1]);
}

void loop() {
  // Your code here
}
Drag options to blanks, or click blank then click option'
A4800
B115200
C19200
D9600
Attempts:
3 left
💡 Hint
Common Mistakes
Using a baud rate not supported by the device.
Forgetting to set the baud rate.
2fill in blank
medium

Complete the code to send the text 'Hello' over serial communication.

Arduino
void loop() {
  Serial.[1]("Hello");
  delay(1000);
}
Drag options to blanks, or click blank then click option'
Aprint
Bwrite
Cprintln
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Using write which sends raw bytes.
Using a non-existent send function.
3fill in blank
hard

Fix the error in the code to read incoming serial data correctly.

Arduino
void loop() {
  if (Serial.[1]() > 0) {
    int incomingByte = Serial.read();
  }
}
Drag options to blanks, or click blank then click option'
Aavailable
BavailableForWrite
CisAvailable
DreadAvailable
Attempts:
3 left
💡 Hint
Common Mistakes
Using availableForWrite which checks if you can write.
Using non-existent functions.
4fill in blank
hard

Fill both blanks to create a simple protocol that sends a command and waits for a response.

Arduino
void loop() {
  Serial.[1]("CMD_START");
  while (Serial.[2]() == 0) {
    // wait for response
  }
}
Drag options to blanks, or click blank then click option'
Aprintln
Bavailable
CavailableForWrite
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using print without newline.
Checking availableForWrite instead of available.
5fill in blank
hard

Fill all three blanks to implement a protocol that sends a command, reads the response, and prints it.

Arduino
void loop() {
  Serial.[1]("GET_DATA");
  while (Serial.[2]() == 0) {}
  int data = Serial.[3]();
  Serial.println(data);
  delay(1000);
}
Drag options to blanks, or click blank then click option'
Aprintln
Bavailable
Cread
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of println.
Using readBytes instead of read.