Complete the code to start serial communication at 9600 baud.
void setup() {
Serial.begin([1]);
}
void loop() {
// your code here
}The Serial.begin() function starts serial communication at the specified baud rate. 9600 is a common speed for debugging.
Complete the code to print the message "Hello" to the Serial Monitor.
void loop() {
Serial.[1]("Hello");
delay(1000);
}Serial.println() prints the message and moves to a new line, making output easier to read.
Fix the error in the code to print the value of variable 'count' to the Serial Monitor.
int count = 5; void loop() { Serial.println([1]); delay(1000); }
To print the value of the variable, use its name without quotes. Quotes would print the word "count" instead.
Fill in the blank to print the sensor value with a label.
void loop() {
int sensorValue = analogRead(A0);
Serial.print([1]);
Serial.println(sensorValue);
delay(500);
}Serial.print() prints the label without a newline. Then Serial.println() prints the sensor value and moves to the next line.
Fill all three blanks to read a button state and print a message accordingly.
int buttonPin = 2; void loop() { int buttonState = digitalRead([1]); if (buttonState [2] HIGH) { Serial.[3]("Button pressed"); } delay(200); }
digitalRead() reads the state of the buttonPin. The if statement checks if the button is pressed (equals HIGH). Serial.println() prints the message with a newline.
