Ⅱ. External sensors and output devices
Connect the infrared sensor to port P2 and the RGB LED to port P1. The program is shown in the
figure above.
Note: The port that you specify for the block of the infrared sensor must be the actual port of
the infrared sensor, which is also the case for the block of the RGB LED. Put the drone on the
open ground, face the drone tail, and then download and run the program to achieve the
following effects:
The drone takes off to 50 cm above the ground. It flies forward at a speed of 30 cm/s until the
infrared sensor detects an obstacle 50 cm ahead. At this time, the RGB LED lights up red and the
drone lands.