Basic motor control using CodeBug

A simple transistor circuit is used here to get the CodeBug to control a small motor, turning it on or off.
Drawn using Schemeit (

The motor used here was a small cell-phone vibration motor, but it has been tried with other small motors.

Using ‘leg 1’ to switch the motor on or off, +5v comes from the CodeBug PWR connector and GND come from the CodeBug. It can only drive the motor in one direction.

In the code below Button A switches on the motor and Button B switches the motor off.

All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with.

Popular posts from this blog

Micro:bit, Servo control with Micropython or blocks

mbots - graphical programming and Arduino

4Tronix Bit:Bot Neuron Controlled Edge follower