Case 3 - Detect black lines with the line follower 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 line follower sensor connected to pin A9 detects a black line and the RGB LEDs are off when the line follower sensor does not detect a black line.

1.gif

Part 2   Preparation

  • MegaPi x 1

  • RGB module x 1

  • Line follower 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 line follower sensor and the RGB module to MegaPi respectively by using the jumpers, open mBlock 5 (PC client or web version), click +add, select mBot Mega from the Device Library, click Connect, and select the Upload mode.

2.gif

3.gif

Part 3   Programming

When the line follower sensor detects a black line, the RGB LEDs are on. Otherwise, the RGB LEDs are off.

4.gif

Part 4   Practice

  1. Try to write a program by which the RGB LEDs are off when the line follower sensor detects a black line and the RGB LEDs are on when the line follower sensor does not detect a black line.

  2. When you turn on mBot Mega, the number of RGB LEDs lighting up equals the number of times the line follower sensor detects a black line.

 

 

Was this article helpful?
2 out of 5 found this helpful

Comments

0 comments

Please sign in to leave a comment.