Complete the code to start serial communication at 9600 baud rate.
void setup() {
Serial.begin([1]);
}
void loop() {
// Your code here
}The standard baud rate for simple serial communication is 9600 bits per second.
Complete the code to send the text 'Hello' over serial communication.
void loop() {
Serial.[1]("Hello");
delay(1000);
}write which sends raw bytes.send function.println sends the text followed by a new line, which is useful for clear output.
Fix the error in the code to read incoming serial data correctly.
void loop() {
if (Serial.[1]() > 0) {
int incomingByte = Serial.read();
}
}availableForWrite which checks if you can write.Serial.available() returns the number of bytes available to read.
Fill both blanks to create a simple protocol that sends a command and waits for a response.
void loop() {
Serial.[1]("CMD_START");
while (Serial.[2]() == 0) {
// wait for response
}
}print without newline.availableForWrite instead of available.Use println to send the command with a newline, and available to check for incoming data.
Fill all three blanks to implement a protocol that sends a command, reads the response, and prints it.
void loop() {
Serial.[1]("GET_DATA");
while (Serial.[2]() == 0) {}
int data = Serial.[3]();
Serial.println(data);
delay(1000);
}print instead of println.readBytes instead of read.Send the command with println, wait until data is available with available, then read the data with read.
