Example Code for Mind+ – Motor Forward/Reverse & Stop

Control the motor to rotate forward, reverse and stop by dragging graphical blocks, no coding required.

Hardware Preparation

  • DFR1278 N20 DC geared motor ×1
  • micro:bit V2 ×1
  • micro:bit掌控IO扩展板 ×1

Software Preparation

Wiring Diagram

DFR1278 Wiring Diagram

Other Preparation Work

  1. Select device and add extensions: Open Mind+, switch to Upload Mode. Go to Controller Extension → Mainboard, select micro:bit V2; Search for and add the Gravity IO Expansion Board extension under Module Extension.
  2. Graphical programming: Drag blocks from the left block area to assemble a simple program (refer to the example diagram).

DFR1278 Sample Code

  1. Upload and verify operation: Connect micro:bit V2 to your computer via USB cable. Click Connect Device in Mind+ and select the corresponding serial port; Click Upload to Device. After upload completes, connect the micro:bit V2 to the Gravity IO Expansion Board and power on the expansion board. The motor will run in a continuous loop: forward rotation for 2 seconds, reverse rotation for 2 seconds, stop for 1 second.

Was this article helpful?

TOP