Test your understanding of using sensor values to control outputs like LEDs
32-Lesson Course • Semester 1
What is the correct pattern for using a sensor to control an output?
In the code if (sensorValue > 500), what does 500 represent?
if (sensorValue > 500)
If sensorValue = 700 and the code is if (sensorValue > 500) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }, what happens?
sensorValue = 700
if (sensorValue > 500) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }
What must you include in setup() to control an LED on pin 13?
setup()
pinMode(13, INPUT)
pinMode(13, OUTPUT)
pinMode(A0, OUTPUT)
How can you create three response levels (Low, Medium, High) from a sensor reading?
What is a benefit of using functions like turnOnLED() and turnOffLED()?
turnOnLED()
turnOffLED()
What does this code do?for (int i = 0; i < 5; i++) { sum += analogRead(sensorPin); delay(50); }
for (int i = 0; i < 5; i++) { sum += analogRead(sensorPin); delay(50); }
What does this line do?int sensorValue = analogRead(sensorPin);
int sensorValue = analogRead(sensorPin);
Explain how you would choose a good threshold value for a light sensor that turns on an LED when it gets dark.
Describe a sensor-controlled project you could build. What sensor would you use, what would it detect, and what output would it control?
These results have been automatically sent to your instructor.