wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CMPE 311 MICROPROCESSORS PRE-FINAL EXAMINATION

Total questions: 100

Worksheet time: 34mins

Name
Class
Date
1.

What is the correct function to set a pin as an output in Arduino?

a)

digitalWrite(13, HIGH)

b)

pinMode(13, INPUT)

c)

analogWrite(13, HIGH)

d)

pinMode(13, OUTPUT

2.

Why won’t the following "blink" code work?

a)

The function digitalWrite should be analogWrite.

b)

The pin should be set to INPUT.

c)

The LED will not blink because there is no LOW state.

d)

delay(1000); is too short.

3.

What common mistake might prevent the built-in LED on pin 13 from blinking?

a)

Forgetting to declare pinMode(13, OUTPUT); in setup().

b)

Using delay(0); instead of delay(1000);

c)

Writing digitalRead(13, HIGH); instead of digitalWrite(13, HIGH);

d)

Using analogWrite(13, 255); instead of digitalWrite(13, HIGH);

4.

If your LED stays on instead of blinking, what could be the problem?

a)

pinMode(13, OUTPUT); is not needed.

b)

The LED might be broken

c)

The code is missing digitalWrite(13, LOW); and a delay.

d)

The delay time is too long.

5.

What will happen if you write delay(-1000);?

a)

The code will not compile.

b)

The delay function will be ignored.

c)

The Arduino will blink the LED faster.

d)

The Arduino will enter an infinite loop.

6.

Why won’t the following code fade an LED property?

a)

The delay is too long.

b)

The loop should count down after reaching 255.

c)

pinMode(9, OUTPUT); should be INPUT.

d)

The pin should be 13, not 9.

7.

What type of pins support analogWrite() for fading LEDs?

a)

Only pin 13

b)

Any pin set to OUTPUT

c)

Digital pins

d)

PWM pins marked with ~

8.

What is the range of values accepted by analogWrite()?

a)

0 to 255

b)

0 to 50

c)

0 to 1023

d)

0 to 100

9.

What common error occurs if you try to fade an LED on pin 2?

a)

The LED will still fade but slower.

b)

The LED will turn on and off instantly.

c)

The code won’t compile

d)

Nothing will happen because pin 2 doesn’t support PWM.

10.

What happens if you use digitalWrite(9, HIGH); instead of analogWrite(9, 255);?

a)

The LED will fade smoothly.

b)

The LED will not light up.

c)

The LED will turn on at full brightness

d)

The LED will blink instead of fade.

11.

What is missing in the following code to display text in the Serial Monitor?

a)

Serial.print() should be used instead of Serial.println().

b)

Serial.begin(9600); should be in loop().

c)

The baud rate should be 115200.

d)

A delay() in loop() to slow output.

12.

Why won’t this code compile?

a)

Serial.println("Testing"); should be Serial.print("Testing");

b)

Serial.start(9600); should be Serial.begin(9600);

c)

The baud rate must be 57600.

d)

There is no delay in loop()

13.

If the Serial Monitor shows garbage characters, what is likely the issue?

a)

The baud rate in the code and Serial Monitor don't match.

b)

The print statement is incorrect

c)

The Arduino board is defective.

d)

The USB cable is unplugged

14.

What will be printed in the Serial Monitor with this code?

a)

HelloHelloHello (without spaces, repeating)*

b)

No output because Serial.println is not used.

c)

Hello

d)

Hello (with a newline after each word)

15.

What is a common mistake when using Serial.read( )?

a)

Using Serial.readString ( ) instead

b)

Forgetting to check if data is available with Serial.available( )

c)

Not setting Serial.begin( )

d)

Using Serial.println( ) instead of Serial.print( )

16.

What happens if you remove the delay(1000); from a "blink" sketch?

a)

The LED will blink faster.

b)

The LED will stay on.

c)

The code won’t compile.

d)

The LED will stay off.

17.

Why won’t this loop execute as expected?

a)

There is an unnecessary semicolon after the for loop.

b)

The loop should count down instead of up.

c)

The loop needs a delay( ).

d)

Serial.println(i); should be inside the loop.

18.

What will be the output of the following code?

a)

It will print numbers starting from 0, increasing infinitely.

b)

The code won’t compile.

c)

It will print numbers 0 to 10, then reset.

d)

It will only print "1" repeatedly.

19.

If a delay of 5000 is used in loop(), what happens?

a)

The delay function will be ignored.

b)

The Arduino will restart.

c)

The LED will blink 5 times per second.

d)

The program will pause for 5 seconds before executing again.

20.

How can you make an LED blink without using delay( )?

a)

Use Serial.print( ) to slow down execution.

b)

Use digitalRead( ) on the LED pin.

c)

Use millis( ) to track elapsed time.

d)

Use millis() to track elapsed time.*

21.

What is the data type for storing whole numbers?

a)

char

b)

float

c)

int

d)

Boolean

22.

What is wrong with the following declaration?

a)

count is declared inside setup( ) and not accessible in loop( ).

b)

Serial.println(count); should be inside setup ( ).

c)

loop( ) must be inside setup( ).

d)

count++ is not a valid operation.

23.

What is the value of x after this code runs?

a)

10

b)

10

c)

5

d)

15

24.

Why won’t the following code compile?

a)

count is declared inside setup( ) and not accessible in loop( ).

b)

Serial.println(count); should be inside setup().

c)

loop() must be inside setup().

d)

count++ is not a valid operation.

25.

What does the bool data type store?

a)

Decimal values

b)

Strings

c)

Whole numbers

d)

True or false values

26.

Why does this code fail to compile?

a)

loop() is inside setup().

b)

setup() is missing curly braces {}.

c)

Serial.begin(9600); is missing.

d)

Serial.println() should be Serial.print().

27.

What is wrong with this conditional statement?

a)

Serial.println should be Serial.print.

b)

Parentheses () are missing around x > 10.

c)

if should be written as IF.

d)

The if statement must be inside loop( )

28.

What will Serial.println(10 / 4); print?

a)

2

b)

2.5

c)

10

d)

10.5

29.

What is wrong with the following function?

a)

Functions cannot have parameters in Arduino.

b)

The return statement should be inside setup().

c)

The parameters must be floats.

d)

void functions cannot return a value.

30.

What does // mean in Arduino code?

a)

It is a syntax error.

b)

It divides numbers.

c)

It is used for comments.

d)

It represents a special character.

31.

Why won’t this program stop at 10?

a)

count never resets, so loop() repeats forever.

b)

count should be float.

c)

The if condition should be count > 10.

d)

Serial.println() should be Serial.print().

32.

What will happen if you forget a semicolon (;) at the end of a statement?

a)

The code will not compile.

b)

The statement will be ignored.

c)

The Arduino will automatically fix it.

d)

The Arduino will crash.

33.

What is missing in this function? void greet() { Serial.println("Hello") }

a)

A return statement

b)

A semicolon after "Hello".

c)

Serial.begin(9600);

d)

The function should be inside loop()

34.

What does millis() do?

a)

Delays execution like delay().

b)

Resets the Arduino.

c)

Returns the number of milliseconds since the Arduino started.

d)

Stops the Arduino for a set time.

35.

What is the purpose of #define LED 13?

a)

It creates a constant named LED representing pin 13.

b)

It sets pin 13 to HIGH.

c)

It turns on the LED connected to pin 13.

d)

It initializes pin 13 as an output.

36.

What is HIGH in Arduino?

a)

A defined constant meaning 1.

b)

A function.

c)

A loop.

d)

A variable.

37.

What is missing from Serial.begin();?

a)

A delay().

b)

A loop statement.

c)

A variable declaration.

d)

A baud rate value.

38.

What does analogRead(A0); do?

a)

Outputs a PWM signal.

b)

Reads a value from an analog sensor on pin A0.

c)

Writes an analog value to pin A0.

d)

Reads a digital signal

39.

What is the purpose of pinMode(LED, OUTPUT);?

a)

It writes a value to the pin.

b)

It sets LED as an output pin.

c)

It turns on the LED.

d)

It reads input from the LED.

40.

What happens if Serial.print() is used without Serial.begin(9600);?

a)

The program won’t compile.

b)

The Serial Monitor will crash

c)

The Arduino will reset.

d)

No output will be displayed.

41.

  int LED1= 4;

What statement is this?

a)

Declaration

b)

void Setup

c)

C language

d)

void loop

42.

int LED1=4;

What is 'int= integer' used for?

a)

Capital and small letters

b)

Combination of Numbers and Alphabets

c)

Alphabets

d)

Numbers

43.

int LED2=8;

What is number eight is referring in the coding above?

a)

Analog Pin

b)

Ground

c)

5V

d)

Digital Pin

44.

digitalWrite (LED1,HIGH);

What does it mean by HIGH?

a)

Switch OFF

b)

Blinking

c)

Switch ON

d)

Sequence

45.

delay (1000);

1000 in delay is equivalent to how many seconds?

a)

2 seconds

b)

10 seconds

c)

1 second

d)

20 seconds

46.

digitalWrite (LED1, HIGH);

  delay (1000);

  digitalWrite (LED1, LOW);

What does the program do?

a)

LED Switch ON at the beginning, wait for 10s and then Switch OFF.

b)

LED Switch ON at the beginning, wait for 1s and then switch OFF.

c)

LED Switch ON at the beginning, wait for 1s and then switch ON.

d)

LED Switch Off at the beginning, wait for 60s and then switch ON.

47.

How long is the LED on?

digitalWrite (13, HIGH);   
delay(1000);   
digitalWrite(13, LOW);   
delay(1000); 

a)

100 seconds

b)

200 seconds

c)

1 second

d)

100 milliseconds

48.

Which symbol ends a statement?

a)

Parenthesis)

b)

Curly Brace }

c)

comma,

d)

semicolon;

49.

Which pin is the jumper wire connected to?

digitalWrite (13, HIGH); 
delay(1000);   
digitalWrite(13, LOW);   
 delay(1000); 

a)

digital pin

b)

100

c)

12

d)

13

50.

A function is a series of programming statements that can be called by name. Which command is called repetitively over and over again as long as the Arduino has power.

a)

(input)

b)

loop()

c)

(output)

d)

setup()

51.

A function is a series of programming statements that can be called by name. Which command is called once when the program starts:

a)

(output)

b)

setup()

c)

loop()

d)

(input)

52.

What does pressing the check-mark do when working with your code?

a)

Checks to see if the Arduino is connected to the computer.

b)

Downloads your code onto the Arduino board.

c)

Saves your work.

d)

Checks your code for mistakes.

53.

What is the definition of function?

a)

Has inputs and outputs

b)

Every input has only ONE output

c)

x-values and y-values

d)

Inputs have different outputs every time

54.

What symbol is used to indicate a comment in Arduino programming?

a)

##

b)

/*

c)

!!

d)

//

55.

How do you declare a variable in Arduino programming?

a)

declare variable_name as data_type;

b)

variable_name data_type;

c)

int variable_name;

d)

data_type variable_name;

56.

How do you write a digital output to a specific pin in Arduino programming?

a)

digitalWrite(pin, value)

b)

setPinOutput(pin, value)

c)

outputDigital(pin, value)

d)

writeDigital(pin, value)

57.

What is the function of the loop() in Arduino programming?

a)

To pause the program for a specified amount of time

b)

To end the program

c)

To execute the program repeatedly after setup() has been called

d)

To execute the program once

58.

What is the function of the delayMicroseconds() function in Arduino programming?

a)

To pause the program for a specified amount of time in microseconds.

b)

To speed up the program execution

c)

To skip a section of the code

d)

To restart the program

59.

LED is setup-up to blink. LEDs is an

a)

Output

b)

Input

c)

pinMode

d)

digitalWrite

60.

What is function of setup () ?

a)

Allowing your program to change and respond.

b)

To initialize variables, pin modes, start using libraries.

c)

It indicates that the function is expected to return no information to the function from which it was called.

d)

None of the above

61.

What is function of void () ?

a)

Allowing the program to change, respond, and control the Arduino board.

b)

To initialize variables, pin modes, start using libraries

c)

It indicates that the function is expected to return no information to the function from which it was called.

d)

None of the above

62.

What is function of loop () ?

a)

Allowing the program to change, respond, and control the Arduino board

b)

It indicates that the function is expected to return no information to the function from which it was called

c)

To initialize variables, pin modes, start using libraries

d)

None of the above

63.

Which one of the following Arduino designs below refer to the code as shown in the figure?

a)

b)

c)

d)

None of the above

64.

Which one of the following Arduino code are TRUE ?

a)

b)

c)

d)

None of the above

65.

Before your program “code” can be sent to the board, it needs to be converted into instructions that the board understands. This process is called...

a)

Compile

b)

Create Sketch

c)

Serial Monitor

d)

Stop

66.

I use temperature sensor to read the room temperature. How do I write Temperature Sensor Set-up.

void setup(){

_______________________;

}

a)

pinMode (Tsensor, INPUT);

b)

PinMode (Tsensor, Output);

c)

PinMode (Tsensor, Input);

d)

pinMode (Tsensor, OUTPUT);

67.

What does IDE stand for?

a)

IDE

b)

Internal Deep Escape

c)

Integrated Development Environment

d)

Integrated Developer's Environment

68.

A program written with the IDE for Arduino is called __.

a)

Source code

b)

TextCode

c)

Sketch

d)

Raw code

69.

What does this sketch do?

a)

This sets up the pin that our LED is connected to as an INPUT pin

b)

This sets up and LED to turn off

c)

This sets up the pin that our LED is connected to as an OUTPUT pin.

d)

Turns the LED off by writing LOW out on the pin.7

70.

What is a Variable?

a)

It is when you want to add two number together

b)

It is a place where you can store some data

c)

It is a name given to a special sub-routine that changes how the program works

d)

It is a place in your code that changes

71.

A function is a series of programming statements that can be called by name. Which command delays the LED by a number of milliseconds is.

a)

delay()

b)

stop()

c)

setup()

d)

loop()

72.

Which LED is ON ?

a)

None

b)

All!

c)

8

d)

9

73.

Where is the position of this command?

pinMode (8, OUTPUT);

a)

void loop()

b)

void setup()

c)

void stop()

d)

None of the above

74.

Where is the position of this command?

digitalWrite(8, HIGH);

a)

void setup()

b)

void stop()

c)

void loop()

d)

None of the above

75.

How header file is to be defined to code for servo motors?

a)

Servo myservo;

b)

#include<Servo.h>

c)

# define Servo

d)

# include Servo

76.

If servo object is myServo and then servo control signal to make 150 degree angle, is coded as

a)

myServo.write(852.5);

b)

myServo.Write(852.5);

c)

analogWrite(852.5);

d)

myServo.write(150);

77.

Servo signal pin must be connected to

a)

any one of the PWM pins

b)

5V pin

c)

any digital pin of Arduino

d)

analog input pins A0 to A5

78.

What type of actuator would be best suited to operating a robot arm?

a)

DC Motor

b)

Servo

c)

Stepper motor

d)

AC motor

79.

Ultrasonic waves are a form of _______ waves

a)

radio

b)

ocean

c)

sound

d)

seismic

80.

How many volts do the ultrasonic sensors need to operate?

a)

12v

b)

5V

c)

10V

d)

3V

81.

An ultrasonic sensor is a device that can measure the ________ to an object by sending out _________ waves.

a)

density / echo

b)

path / seismic

c)

distance / sound

d)

elevation / sonic

82.

What type of sensor would be used in this kettle?

a)

Infra-red sensor

b)

Temperature Sensor

c)

Pressure Sensor

d)

Light Sensor

83.

What is the minimum Voltage to power up an Arduino uno module?

a)

0. 5 V

b)

0. 24 V

c)

12V

d)

0. 4V

84.

What is the code used to input a library on your sketch?

a)

#include

b)

#define

c)

#input

d)

#determine

85.

What is the function of the setup() in Arduino programming?

a)

It is used to play music on the Arduino board

b)

It is used to initialize the Arduino board and prepare it for the main loop

c)

It is used to control the speed of the Arduino board

d)

It is used to turn off the Arduino board

86.

What is the function of the loop() in Arduino programming?

a)

Runs the code only once

b)

Stops the code from running

c)

Resets the Arduino board

d)

Executes the code continuously

87.

What is the syntax for declaring a variable in Arduino programming?

a)

data_type variable_name;

b)

variable_name = data_type;

c)

variable_name data_type;

d)

variable_name = new data_type;

88.

What is the difference between digitalRead() and digitalWrite() functions in Arduino programming?

a)

They are used for controlling servo motors

b)

They are used for measuring temperature

c)

They are used for reading and writing digital signals on Arduino pins.

d)

They are used for playing sound

89.

Explain the use of the analogRead() function in Arduino programming.

a)

It is used to measure the frequency of an analog signal.

b)

It is used to read the analog voltage value from a specified analog pin.

c)

It is used to write digital values to an analog pin.

d)

It is used to control the speed of a servo motor.

90.

What is the primary purpose of the Fritzing software?

a)

To manage databases

b)

To create prototypes and schematics

c)

To design 3D models

d)

To program Arduino boards

91.

What is the function of the TX and RX LEDs?

a)

To show power status.

b)

To indicate the board is connected.

c)

To indicate serial communication

d)

To display error messages.

92.

What is the correct execution process of an Arduino code?

a)

Editor->Preprocessor->Compiler

b)

Preprocessor->Editor->Compiler

c)

Compiler->Preprocessor->Editor

d)

ditor->Compiler->Preprocessor

93.

What is the function of the IOREF pin on the Arduino UNO?

a)

To take input voltage and set it as a reference for all GPIO operations

b)

To provide a constant 12V DC supply

c)

To provide ground

d)

To provide the voltage corresponding to the standard GPIO working voltage of the board

94.

What will be the output of the following Arduino code?

#define X 10; void setup(){ X=0; Serial.begin(9600); Serial.print(X); } void loop(){ //Do nothing… }

a)

0xAB

b)

0xa

c)

0

d)

Error

95.

What is the purpose of the following Arduino code?

  1. void setup() {

  2. Serial.begin(9600);

  3. }

  4. void setup() {

  5. Serial.write(40);

  6. }

a)

Send a signal to pin 40 on the Arduino board

b)

Send a octal number of 40 through the Serial pins

c)

Send a byte with value 40 through the Serial pins

d)

Send a hexadecimal number of 40 through the Serial pins

96.

What is the use of the Interrupt Service Routine in an Arduino?

a)

To boot up the Arduino

b)

To exit any code that is running

c)

To automate functions

d)

To make more memory

97.

What is the full form of UART?

a)

Universal Asynchronous Receiver/Transmitter

b)

Universal Anti-Rectifying Transmitter

c)

Universal Asynchronous Radio Transmitter

d)

Universal Asynchronous Rectifier Transistor

98.

What is the purpose of the tone() function?

a)

To generate a sine wave

b)

To generate a cosine wave

c)

To generate a stable voltage level

d)

To generate a square wave

99.

Which of the following control structures is an exit-controlled loop?

a)

For loop

b)

While loop

c)

Const and Goto

d)

Do-While loop

100.

What is the name of the control structure used to stop any loop prematurely and only exit out of the loop, not affecting the running of the rest of the program?

a)

The continue statement

b)

The break statement

c)

The exit statement

d)

The purge statement