14. case 11 DC motor#

14.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.

14.3. Hardware Connect#

../../_images/rKbr0NQ.png

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

14.4. Principles of Circuits#

../../_images/cBDx8Qv.png

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

14.5. 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.

../../_images/case-13-4.png

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

14.6. Software#

Step 1#

Click makecode https://makecode.microbit.org/#

Click on “New Project” and set a new Project.

../../_images/t34k5Zb.png

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.

../../_images/hHQ0Ayz.png

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.

../../_images/3UfQLdB.png

Program#

Program link:https://makecode.microbit.org/_Y94cmyMePXsh

You also could directly download program by visiting website as below:

14.7. Result#

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

14.8. Think#

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

14.9. Questions#

14.10. More Information#