wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PIF-Quiz 4

Total questions: 15

Worksheet time: 5mins

Name
Class
Date
1.
What is the output of the following code? <br> int x = 5;<br> x = x + 2;<br> Serial.println(x);
a)
2
b)
7
c)
5
d)
10
2.
What does the following code do? <br> pinMode(13, OUTPUT);
a)
Reads the state of digital pin 13
b)
Sets digital pin 13 to high
c)
Sets digital pin 13 to low
d)
Configures digital pin 13 as an output
3.
Which function is used to read the value of an analog pin in Arduino?
a)
digitalRead()
b)
analogRead()
c)
pinMode()
d)
digitalWrite()
4.
What is the purpose of the delay() function in Arduino?
a)
To read data from a sensor
b)
To print output to the serial monitor
c)
To pause the program execution for a specified time
d)
To define a function
5.
What is the correct way to declare a constant variable named "LED_PIN" with a value of 9 in Arduino?
a)
const int LED_PIN = 9;
b)
int const LED_PIN = 9;
c)
#define LED_PIN 9
d)
All of the above
6.
Which operator is used to check if two values are NOT equal in Arduino?
a)
=
b)
==
c)
!=
d)
>
7.
What is the purpose of a comment in Arduino code?
a)
To tell the Arduino what to do
b)
To make the code look nicer
c)
To explain the code to humans
d)
To store data
8.
What is the output of the following code? <br> int x = 10;<br> int y = 5;<br> if (x > y) {<br> Serial.println("x is greater");<br> } <br> else {<br> Serial.println("y is greater");<br> }
a)
x is greater
b)
y is greater
c)
x is less
d)
y is less
9.
What does the following code do? <br> for (int i = 0; i < 5; i++) {<br> Serial.println(i);<br> }
a)
Prints the numbers 0 to 4
b)
Prints the number 5
c)
Prints the numbers 1 to 5
d)
Prints the numbers 0 to 5
10.
Which Arduino function is used to send data to the serial monitor?
a)
print()
b)
Serial.print()
c)
Serial.println()
d)
Both B and C
11.
What is the purpose of the Serial.begin() function in Arduino?
a)
To start reading data from a sensor
b)
To initialize the serial communication
c)
To turn on the Arduino board
d)
To define a variable
12.
What is the correct way to include the Servo library in your Arduino code?
a)
#include <Servo.h>
b)
#include <servo>
c)
import Servo
d)
library Servo
13.
Which component is essential for controlling a servo motor with Arduino?
a)
Resistor
b)
LED
c)
Potentiometer
d)
Servo motor object
14.
What is the function of the servo.write() function in Arduino?
a)
To read the position of the servo motor
b)
To set the angle of the servo motor
c)
To initialize the servo motor
d)
To define the servo motor pin
15.
What is the range of angles that a standard servo motor can typically rotate?
a)
0 to 90 degrees
b)
0 to 180 degrees
c)
0 to 270 degrees
d)
0 to 360 degrees