(distance < 4) {
if
// When the Red condition is met, the Green LED
should turn off
digitalWrite
digitalWrite
}
{
else
digitalWrite
digitalWrite
}
(distance >= 200 || distance <= 0){
if
Serial.println
}
else
{
Serial.print
Serial.println
}
(500);
delay
}
Procedure
1.
Prepare a sketch with the given code and upload it to your
board.
2.
Connect the module/component to the board as shown in
the connection diagram or table.
3.
Approach the sensor within its range with an object.
4.
Measurements are output to the Serial Monitor.
Specifications
Operating voltage
Quiescent Current
Working Current
Measuring Angle
Effectual Angle
(led,
);
HIGH
(led2,
);
LOW
(led,
);
LOW
(led2,
);
HIGH
("Out of range");
(distance);
(" cm");
+5 V/DC
<2 mA
15 mA
30°
<15°
4