Case 2 - Obstacle Detection with Obstacle Avoidance Sensor

Case 2 - Obstacle Detection with Obstacle Avoidance Sensor

Part 1   Objective

After you upload the program, the RGB LEDs on the RGB module connected to pin A13 on MegaPi are on when the obstacle avoidance sensor connected to pin A6 detects an obstacle and the RGB LEDs are off when the obstacle avoidance sensor does not detect an obstacle.

77.gif

Part 2   Preparation

  • MegaPi x 1

  • RGB module x 1

  • Obstacle avoidance sensor x 1

  • 3-pin jumper x 2

  • USB cable x 1

  • Computer with network access x 1

Connect MegaPi to the computer by using the cable, connect the obstacle avoidance sensor and the RGB module to MegaPi respectively by using the jumpers, open mBlock 5 (PC client, web version, or mobile app), click +add, select mBot Mega from the Device Library, click Connect, and select the Upload mode.

88.gif
99.gif

Part 3   Programming

  1. When the obstacle avoidance sensor detects an obstacle, the RGB LEDs are on. Otherwise, the RGB LEDs are off.

100.gif

Part 4   Practice

  1. Try to write a program by which the RGB LEDs are off when the obstacle avoidance sensor detects an obstacle and the RGB LEDs are on when the obstacle avoidance sensor does not detect an obstacle.

  2. When you turn on mBot Mega, the number of RGB LEDs lighting up equals the number of times the obstacle avoidance sensor detects an obstacle.

 

 

Was this article helpful?
0 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.