WorksheetsEngineering challenge light box test
Total questions: 36
Worksheet time: 17mins
What three sections of code did you have in the Arduino project sketch?
Comment block, variable definitions, and run section.
Comment block, if section, and loop function.
Variable definitions, loop function, and finalize function.
Variable definitions, setup function, and loop function.
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH); delay(1000);
digitalWrite(13, LOW); delay(1000);
}
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH); delay(1000);
digitalWrite(13, LOW); delay(1000);
}
pinMode() function configures a pin as either ______or In ________What is the symbol used for the logical AND in an "if" statement?
||
&&
*
@
What does the "void" statement mean before the "setup" and "loop" functions?
The function needs no variables.
The function takes no input.
The function returns nothing.
The function returns a variable named "void".
For a "threshold" value of 500 and a "readInput" value of 425, what happens in the following code?
if ( readInput > threshold)
{
digitalWrite(LEDpin1, HIGH);
digitalWrite(LEDpin2, HIGH);
}
else
{
digitalWrite(LEDpin1, LOW);
digitalWrite(LEDpin2, LOW);
}
LEDpin1 and LEDpin2 are turned on
LEDpin1 and LEDpin2 are turned off
Nothing happens to LEDpin1 and LEDpin2
Colt falls at 9.8 meters per second
What's the difference between analogWrite and digitalWrite? analogWrite(pin,0-255) vs digitalWrite(pin,LOW-HIGH)
There is no difference in the two commands, they simply take different input values.
digitalWrite will set the specified pin to one of two states, where analogWrite can set the pin to different values
digitalWrite is used to control an LED and analogWrite is not
digitalWrite can only be used in the loop() function and analogWrite can only be used in the setup() function
Select the best answers based on the following code. When will LEDpin1 turn on?
if ((threshold > 400) && (threshold < 500))
{
digitalWrite(LEDpin1, HIGH);
}
else if ((threshold > 300) && (threshold < 400))
{
digitalWrite(LEDpin1, HIGH);
digitalWrite(LEDpin2, HIGH);
}
else
{
digitalWrite(LEDpin1, LOW);
digitalWrite(LEDpin2, LOW);
}
If the threshold value is 475.
If the threshold value is 350
if the threshold value is 550
If the threshold value is 275
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH); delay(1000);
digitalWrite(13, LOW); delay(1000);
}
