Case 9 - Use a motor to control another motor

Part 1   Objective

After you compile the program, you can control the rotation speed and direction of motor 2 by rotating motor 1.

32.gif

Part 2   Preparation

  • MegaPi x 1

  • MegaPi RJ25 adapter x 1

  • RJ25 cable x 1

  • MegaPi encoder/DC motor driver x 2

  • Photoelectric encoder motor 185RPM with wheel × 2

  • Encoder motor cable x 2

  • USB cable (Type-B) x 1

  • Battery holder with 6 AA batteries x 1

  • Computer with network access x 1

Install the MegaPi RJ25 adapter and the MegaPi encoder/DC motor drivers on MegaPi, connect the encoder motors to MegaPi by using the encoder motor cables, connect the battery holder to MegaPi, connect MegaPi to the computer by using the USB cable, open mBlock 5 (PC client or web version), click +add, select Ultimate 2.0 from the Device Library, click Connect, and select the Live mode.

33.gif

34.gif

Part 3   Programming

Set the rotation speed of the motor connected to port 2 as that of the motor connected to port 1. You can set the rotation speed of the motor connected to port 2 fifty times (or any other times) that of the motor connected to port 1 for a more obvious effect.

35.gif

Part 4   Practice

Try to write a program with other motor-related blocks.

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

Comments

0 comments

Please sign in to leave a comment.