PROJECT - USE MOSFET TO DRIVE AN LED

Objective: demonstrate use of MOSFET

You will need: Raspberry Pi, IRLZ44N MOSFET, LED, 10kΩ and 330Ω resistors, patch leads and small breadboard.

INTRODUCTION

IRLZ44N MOSFET

This project demonstrates a simple use of a MOSFET to drive an LED. The Raspberry Pi can drive LEDs without needing to use a MOSFET but where the load on a single pin is more than 40mA or the combined load on all pins is more than 200mA a MOSFET or transistor is needed. You'll also need a MOSFET if you wish to drive a 5V mechanical relay as the current required is about 100mA and more than a single pin can provide.

To use a MOSFET successfully with microcontroller output voltages, you need a logic level MOSFET; these are usually identifiable by an L in the part number, e.g. IRLZ44N or IRL540.

Logic level MOSFETs, such as the IRLZ44N, can be used with Raspberry Pi projects to switch high currents at voltages higher than 5V. The International Rectifier device will switch 47A at up to 55V, subject to being fitted to a suitable heat-sink and de-rated for its expected operational temperature. Not all IRLZ44Ns have the same specification with regards to current limits so check the corresponding datasheet for details of your device. For the TO-220 package the pins are, from left to right in the diagram above, Gate, Drain, Source.

Link to source code. You will need to use the following commands to compile and run the program. You will be using the wiringPi library so it needs to be included on the command line:

gcc rp-blink-mosfet.c -o rp-blink-mosfet -lwiringPi

./rp-blink-mosfet

MOSFET and LED wiring diagram

Do this with an ESP8266 or a Arduino.