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 crash sensor connected to pin A11 detects a crash and the RGB LEDs are off when the crash sensor does not detect a crash.
Part 2 Preparation
MegaPi x 1
RGB module x 1
Crash 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 crash 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.
Part 3 Programming
When the crash sensor detects a crash, the RGB LEDs are on. Otherwise, the RGB LEDs are off.
Part 4 Practice
Try to write a program by which the RGB LEDs are off when the crash sensor detects a crash and the RGB LEDs are on when the crash sensor does not detect a crash.
When you turn on mBot Mega, the number of RGB LEDs lighting up equals the number of times the crash sensor detects a crash.
Please sign in to leave a comment.