NEW
Font size
Worksheets15-Question Arduino Coding Flow Review
Total questions: 15
Worksheet time: 8mins
SEQUENCE: When writing an Arduino sketch, what is the absolute first section the code compiler reads, even before void setup()?
The void loop() function.
The Serial Monitor output settings.
The Global Declaration section.
The if/else logic statements.
FORMATTING: A student wants to assign the name SOIL_SENSOR to analog pin A1. Which line correctly defines this constant variable?
int A1 = SOIL_SENSOR;
string SOIL_SENSOR = A1;
const int SOIL_SENSOR = A1;
void SOIL_SENSOR() = A1;
VARIABLE SCOPE: If you define a variable in the Declaration section (at the top), can you use it inside both void setup() and void loop()?
No, only one function can use a variable.
Yes, because it is a global variable.
Only if you use the analogRead() function.
Only if you name the variable const.
EXECUTION: How many times is the code inside the void setup() function executed?
It runs repeatedly, about once per second.
It runs only when a sensor changes value.
Exactly one time, when the Arduino powers on or resets.
It runs after the void loop() function finishes.
PIN CONFIGURATION: The water level sensor sends data to the Arduino via pin A0. Which is the correctly formatted command to configure this pin?
digitalWrite(A0, INPUT);
pinMode(A0, INPUT);
pinMode(INPUT, A0);
pinMode(A0, OUTPUT);
COMMUNICATION: Why must the Serial.begin(9600); command be placed inside void setup()?
Because the sensor reading is needed only once.
Because the communication speed only needs to be established once.
To ensure the delay function works correctly.
To make the status print faster than 9600.
DATA READING: Which line correctly reads the sensor value from the pin named SOIL_SENSOR and stores the result in a local variable?
analogRead(SOIL_SENSOR) = soilValue;
digitalRead(SOIL_SENSOR) = int soilValue;
int soilValue = analogRead(SOIL_SENSOR);
soilValue = digitalRead(SOIL_SENSOR);
ANALOG RANGE: The analogRead() function returns a value proportional to the voltage. What is the full range of values it can read?
0 to 255
0 to 1023
1 to 100
0 to 9600
TIMING CONTROL: If the Serial Monitor prints sensor data too quickly, what command is required at the end of void loop() to pause the program for two seconds before it repeats?
delay(2);
pause(2000);
delay(2000);
sleep(2);
WATER SENSOR LOGIC: When the water sensor reading is high (e.g., 800), it means the water level is high. Which comparison operator correctly checks for a HIGH LEVEL if the threshold is 300?
waterValue < 300
waterValue == 300
waterValue > 300
waterValue != 300
SOIL SENSOR LOGIC: When the soil sensor reading is low (e.g., 150), it means the soil is wet. Which comparison operator correctly checks for WET SOIL if the threshold is 500?
soilValue < 500
soilValue > 500
soilValue >= 500
soilValue != 500
IF/ELSE EXECUTION: In an if/else statement, if the condition in the if block is FALSE, what happens next?
The program stops and waits for a button press.
The entire conditional statement is skipped.
The code inside the else block executes.
The program returns to void setup().
TROUBLESHOOTING: The Serial Monitor shows your pin reading 1023 all the time, even when the sensor is placed in water. What is the most likely error in void setup()?
Missing delay(1000);
The pin was set as OUTPUT instead of INPUT.
The Serial.begin() command is missing.
The variable in the Declaration section is wrong.
LCD FORMATTING: To display the sensor status on the bottom row of a 16x2 LCD, which command correctly positions the cursor at the start of that row?
lcd.setCursor(1, 0);
lcd.setCursor(16, 2);
lcd.setCursor(0, 1);
lcd.print("Bottom Row");
DEBUGGING LOGIC: Your code reports "DRY SOIL" when the soilValue is 600, but you know that 600 should be considered the start of "WET SOIL." Which single line in your code do you need to adjust?
The pinMode setting.
The delay() time.
The threshold value (e.g., changing 500 to 650) in the if statement.
The analogRead() function.
