Just like what we did in our first project, we control the brightness of a LED using potentiometer, we will be using a motor instead of the LED, the only difference is we will introduce BJT to our circuit. The reason we use BJT is because the digital output pins on the Arduino is not powerful enough to power a motor, so we have to have an external power source for the motor. The BJT can be controlled by Arduino output pin, to provide varying power to the motor, thus varying speed.
Actually, it’s not right to say ‘varying power’ here, because it’s a analogue term, and the output pins on an arduino are all digital (can only give constant voltage of HIGH or LOW). The ‘varying voltage’ we see, comes from a useful technique call PWM (pulse-width modulation). It basically varies the percentage of time that the output is HIGH, thus varies the total power it gives. Let me know if you have trouble with it.
coming soon, just realised I haven’t got a BJT… will order some