My Cart:

0 item(s) - £0.00
You have no items in your shopping cart.

Inventors Kit Experiment 4 Full Experiment

In this tutorial you will find Experiment 4 Using a Transistor to drive a Motor from the Kitronik Inventors Kit for the BBC micro:bit. We've included the entire experiment as a free example of the great practical experiments that are contained within the Inventors Kit. Learn how to build the circuit and how to code the micro:bit to control the circuit.

Experiment 4 Using a Transistor to drive a Motor-main-image-870

You can complete this experiment with or without the Inventors Kit. If you do not have the Kitronik Inventors Kit you will have to source all of the required components separately, a full list of the things you will need can be found below.


This Experiment Requires:


The Aims Of This Experiment Are:

  • To use a transistor to drive a fan motor.
  • To control the speed of the motor using Pulse Width Modulation (PWM).


Experiment 4 Video Walk Through:


Experiment 4 Using A Transistor To Drive A Motor:

The output pins on most microprocessors can only supply a small amount of current, not enough for a power hungry device such as a motor. The BBC micro:bit is no exception to this. A transistor can be used to solve this problem.

A transistor is like a gate for electricity, a small amount of current can be used to open the gate to let a lot of current flow through to power hungry components.


Creating The Code Using The Microsoft Block Editor:

Below is an example of how to write the code for the experiment in the Microsoft Block Editor.


If you're having difficulty producing your own code for this experiment, we've created the code for you that you can compile, download and place onto your BBC micro:bit. To get the code, follow this link.

To use the code; Follow the link above and select Edit. Press the Compile button and the code will be compiled and will automatically download via your browser. Plug your BBC micro:bit into a USB slot on your computer, your computer will now see the micro:bit as a removable drive. You can drag the downloaded hex file directly onto your micro bit. On some systems the hex file may not show up as being on the micro:bit, but it is there.


Building This Circuit On The Prototyping System:

It is possible to build this circuit using the Prototyping System for the BBC micro:bit and the components listed at the top of the page, you can follow the diagram below.


Building This Circuit With Crocodile Leads:


If you don't have the Kitronik Inventors Kit for the BBC micro:bit or the Prototyping System you can still build this circuit using the circuit diagram for reference and Crocodile Leads to join the components together. You can see an example of this in the picture below.

When connecting the Transistor it is important to correctly identify the Base, Collector and Emitter leads. These can be seen in the picture to the right. Care should also be taken when connecting the transistor to ensure that there are no shorts, you should bend the pins away from each other before you connect the crocodile leads.


Circuit Diagram:



What Will Happen:

The motor should, after a few seconds start to spin slowly, then faster until it reaches a maximum speed. At this point it will slow down and stop and the cycle will begin again.


What's Going On (How Does It work)?:

If the transistor is turned on and off very quickly and it spends half its time on and half its time off then the fan motor will spin at half speed. By changing the percentage of the time that the transistor spends on (known as the duty cycle) the speed of the motor can be finely controlled. As the power pulses on and off and the width of the pulses are controlled, we call this process Pulse Width Modulation (PWM).

The code works in two stages. The first loop writes the duty value to Pin P0 then increases the duty value by one and writes the value to P0 again. This repeats until the value reaches the maximum of 1023 (full speed). The second loop then kicks in and reduces the duty by 1 and writes it to P0 until the value reaches 0 (stopped). This whole cycle is inside a forever loop so the motor will speed up and slow down forever. The PWM output varies the duty cycle of the output voltage, as show below, to vary the speed of the fan motor.


Inventors Kit Experiment 4 Further Help Code Examples:


Kitronik Inventors Kit Resources:

Exp No#. Experiment Name. Resource Type.
1 Say Hello to the BBC micro:bit. Further Help.
2 Using an LDR and analog inputs. Full Experiment + Further Help.
3 Dimming an LED using a potentiometer. Further Help.
4 Using a transistor to drive a motor. Full Experiment + Further Help.
5 Using the accelerometer to control motor speed. Further Help.
6 Setting the tone with a piezo buzzer. Further Help.
7 Wind Power. Full Experiment + Further Help.
8 Making a game using the compass. Further Help.
9 Capacitor charge circuit. Further Help.
10 Using an RGB LED. Further Help.
11 Making a pedestrian crossing. Full Experiment + Further Help.
12 Making a random dice. Full Experiment + Further Help.


Get The Kitronik Inventors Kit For The BBC microbit:

We do two versions of the Inventors Kit for the BBC micro:bit, with or without the BBC micro:bit included. Chose the option that is right for you from the links below.

Free Delivery
← Previous Post Next Post →

Leave a Reply