What will the output of the code be if the relative velocity between the object and the sensor is 0, and it is within the range of the

Ngọc Trâm

New member
What will the output of the code be if the relative velocity between the object and the sensor is 0, and it is within the range of the sensor for the entire time both are moving?
Code:
int op = 6;
int isObstacle = HIGH;
void setup() {
    pinMode(op, INPUT);
    Serial.begin(9600);
} 
void loop() { 
    isObstacle = digitalRead(op);
    if (isObstacle == LOW) { 
        Serial.println("1+"); 
    } 
    else {
        Serial.print("clear+"); 
    } 
    delay(200);
}
A. clear+clear+1+1
B. 1+1+clear+clear
C. clear+clear+clear+clear
D. 1+1+1+1
 
Answer: D
Explanation: If the relative velocity of the sensor with respect to the object is 0, then effectively it means that the object is stationary when compared to the sensor, so in that movement, since the object is within the sensor’s range, the sensor detects that the object is continuously within range hence the output will be continuously “1+”.
 

Tìm kiếm

Back
Top