Skip to main content

Controlling an actuator with a N-channel Mosfet

What is the TinkerKit Mosfet?

TheA TinkerKitMOSFET Mosfet(Metal-Oxide-Semiconductor Field-Effect Transistor) is a simpletype moduleof fortransistor controllingused devicesto likeswitch motors,or solenoids,amplify LEDelectrical stripssignals in electronic devices. It’s one of the most common components in electronic circuits, especially in digital and electromagnetsanalog whichsystems.

require

Structure

higher

A voltagesMOSFET has three main terminals — Gate, Drain, and currentsSource. thanThe Gate is separated from the Arduinochannel by a thin insulating layer of silicon dioxide (SiO₂).

Operation

A small voltage applied to the Gate controls the current flow between the Drain and Source terminals. By adjusting this voltage, the MOSFET can handleact alone.

as

Typicallya youswitch might(turning findthe current on or off) or as an exampleamplifier (controlling the level of a mosfet circuit online when trying to solve this problem, however high current circuits can melt breadboards, and accidentally wiring up the 12 or 24 volt power supply to your Arduino is a easily made mistake that will damage the Arduino and potentially your computer.flow).

For this reason we use a small, cheap module which takes away all these headaches, on the Arduino side you have three header pins and on the actuator side you've got your power in, and switched power out.

In effect TinkerKit Mosfet is an electronic switch that can turn your actuator on and off using an Arduino.

Wiring

Types

There are threetwo wiresmain totypes connectof onMOSFETs, thewe Arduinowill side:be using a N-channel Mosfet in this tutorial.e

  1. GroundN-channel MOSFETs: These conduct when a positive voltage is applied to the Gate relative to the Source.
  2. P-channel MOSFETs: These conduct when a negative voltage is applied to the Gate relative to the Source.

Wiring

  1. Source (- connectsS) to GND
  2. Drain (D) to actuator(-) & to diode(-)
  3. Gate (G) to GND via 1k resistor & to Pin 13
  4. Power (Supply(+ connects) to 5Vactuator(+) & diode(+)
  5. SignalPower (The middle pin connectsSupply(-) to yourGND Arduino pin e.g. pin 6)

On the other side there are four screw terminals, labeled:

  • GND (Connects to your power supply ground)
  • +V (Connects to your power supply positive)
  • M+ (Connects to one side of your actuator)
  • M- (Connects to the other side of your actuator)

**Warning**
The TinkerKit Mosfet can only drive up to 24V DC.

TinkerKit Mosfet.png

Getting started

After wiring up the board it can be controlled via digitalWrite just like an LED. There are some quick examples below:mosfet.png

Basic Example

This basic example is effectively the blink sketch, the TinkerKit Mosfet operates just like any other digital device.

#define actuatorPin 613
    
void setup() {
      pinMode( actuatorPin, OUTPUT );
    }
    
void loop() {
      digitalWrite( actuatorPin, HIGH );
      delay( 1000 );
      
      digitalWrite( actuatorPin, LOW );
      delay( 1000 );
    }

Advanced Example

You can also control the speed of some actuators, normally this is only useful for motors, this is accomplished using analogWrite (PWM) this is effectively the same as setting the brightness of an LED.

**Danger**
Below a certain voltage/PWM value most actuators such as motors will stall (won't turn), this will cause the motor to become extremely hot potentially causing a fire damaging the motor, or burning you.

Always make sure your code prevents the speed of the motor going below the stall speed, you can find the stall speed by testing different values until the motor is only just turning, this should be your minimum.

#define actuatorPin 6

void setup() {
  pinMode( actuatorPin, OUTPUT );
}

void loop() {
  // This example uses 128 as an example of the minimum motor speed to protect the motor
  for ( int i = 128; i < 255; i++ ) {
    analogWrite( actuatorPin, i );
    delay( 10 );
  }
}