13. case 11 DC motor

13.1. Introduction

  • The servo is a device that can transfer electric energy to kinetic energy based on a law of electromagnetic induction. In this case, we will use a switch to turn the motor on and off.

13.2. Hardware Connect


  • Connect circuit as above picture and put 2 AAA batteries into batteries pack.

13.3. Principles of Circuits


  • The GND of slot on micro:bit is into innards of batteries’ GND to generate the current loop.

13.4. Introduction of Components

DC Motor

  • There are many categories of motors, but a motor basically transforms electric energy into kinetic energy according to the rule of electromagnetic induction. When the direct voltage was added on the two sides of the motor, the motor turns. The higher the voltage, the faster the rotation.

  • The experiment box included a DC motor, and it connects a fan to show rotation.


Note: Please note the positive and the negative when you are connecting.

13.5. Software

Step 1


Step 2

  • Under the on start block, Wirte 0 to the P0 port to prevent motor from mis operated. Set pull pin P1 to up for waiting button signal.


Step 3

  • Judge the value of P1 if it is equal to 0. If it is, write 1 to the P0 port for starting the servo; If it is not, write 0 to the P0 port to stopping the servo.



13.6. Result

  • Press switch, the motor runs; press it again, the motor stops.

13.7. Think

  • How can we use the trimpot to control the speed of the motor?

13.8. Questions

13.9. More Information