-
-
Notifications
You must be signed in to change notification settings - Fork 111
How to control backlight leds (and your annunciators too!) with a MOSFET and one PWM pin
Even though you have a lot of output pins in an Arduino Mega, it is not practical, nor sensible, to use them for backlight control with individual leds.
Of course the most straight forward approach is to use a cheap 12V led dimmer module and route warm white led strips behind your panels, but you might have several independent panels that would then need to be separately daisy chained for their backlight. While this is certainly possible to do, it can be impractical, depending on how your panels are located and used.
Also, you cannot easily sync the backlight with the dimmer in the simulator. While this is not an issue if you are building a full cockpit simulator (and thus would never see the simulated cockpit) there are different kinds of builds, and many of them are used together with the virtual panels, at least until we wade further down the rabbit holes of cockpit building.
A fet is a type of a transistor - a semiconductor component that is one of the basic building blocks of pretty much anything that uses electricity. The typical FET has three pins, and it acts a bit like a water hose valve. The SOURCE
is connected to DRAIN
and the flow is controlled by the GATE
pin. While there are many kinds of transistors and FETs, we are focusing on a N-type, logic level mosfet, of which one very common one is IRLZ44.
Using a FET has several advantages: You can use a separate power supply to power your leds, thus you are not limited with the 500mA maximum available from USB. You can also use one arduino pin to control all your backlight leds at once.
So you need a N-type, logic level FET. Our circuit needs a N-type fet, and a logic level component means the control pin is compatible with 0 to 5V signal levels, that most Arduinos use. If you are making something for the RP2040 that operates at 3.3V, you can also find FETs that are designed for 0 to 3.3V operation.
The circuit is very simple - we are basically creating a programmable switch on the ground wire of your backlight leds, that cuts off the GND wire for your led circuit. If you use 12V for your leds, you can wire your leds in strands of 3 that are in series, and add as many of them in parallel as you need. As white leds usually have approximatgely 3.5V voltage drop, you get 3 x 3.5V = 10.5V and adding a suitably sized resistor as a safety measure in case one of the leds decides to fail.
The circuit also has two resistors - one 10K Ohm pulldown resistor that ensures the circuit does not light up on its own, as it connects the gate pin to ground when the arduino is not powered. There is also another resistor, valued at 1k Ohm that is placed between the Arduino pin and the gate, to protect the pin from possible voltage spikes. While this is generally not as big of an issue with led lights compared to say running an electric motor, it still is a reasonable practice to add one just in case.
- MobiFlight Connector Installation
- Mobiflight Connector BETA version installation
- Modules
- MobiFlight Connector Files Structure
- MobiFlight Connector Uninstall
- Modules Reset to factory default
- Verifying the WASM module installation and locating the MSFS2020 community folder
- Verifying the WASM module installation and locating the MSFS2024 community folder
- Using a Winwing FCU with MobiFlight
- Using VKB controllers with MobiFlight
- Providing logs from MobiFlight
- MobiFlight Connector How does it work
- Mobiflight Connector Main Window
- Flash module with MobiFlight firmware
- Input and Output devices
- Joysticks
- Midi Boards
- Sim Variables (for Output)
- Input Actions
- Merging configuration files
- Disabling specific COM ports
- Examples Output LEDs
- Examples Input Switch
- Example 7 segment display
- Example Servo motor
- Controlling LEDs with an output shift register
- Adding lots of buttons with an input shift register
- Beginner's guide to input multiplexers
- Key Matrix with standard MobiFlight and Multiplexers
- Tutorial Easy Driver and x.27 or x.40 Stepper Motor
- Tutorial for Airbus VS display via 7-Segment LED Module
- Example Analog Input Potentiometer
- Baron G58 Tutorial Gear, Flaps, Mags, ELT Input Output Programming
- Using Mobiflight to control arduino-based 3rd party panels (RealSimGear GNS530)
- How to use a VNH2SP30 DC motor shield with MobiFlight
- Using 3D printer mainboards
- Playing sounds by sending keystrokes to AutoHotKey
- Using the selector knob on a Honeycomb Bravo
- Using an adjustable 12 position switch as a GA starter
- Brightness of LCD displays with I2C
- Using three-position switches
- Transponder with one Rotary
- Workflow for Creating Flight Simulation Panels ‐ Part 1
- MSFS2020 RPN Tips and Tricks
- MSFS2020 Using the Custom Input Code Box
- MSFS2020 Install WASM module and Event List
- MSFS2020 How to Create and Use User Defined Lvars
- MSFS2020 How to Create a Blinking LED configuration
- MSFS2020 User Defined WASM Module Events Best Practices
- MSFS2020 Developer Mode, Model Behavior dialog and Console window
- MSFS2020 PMDG 737‐700 List of Events that require use of FSUIPC7
-
MSFS2020 PMDG 737‐700 Calibrate throttle idle and reverse thrust using interpolation (Valkyrie)
- MSFS2020 PMDG 737-700 Chrono unit functions implemented in Mobiflight
- Configuring PMDG 737 Parking Brake Lever Auto-Release with a Servo in Mobiflight
- Using encoder to drive a value back and forth within a given range
- Adding a custom board to MobiFlight
- User guide - Community Board and Custom Devices
- Developing your own custom devices/boards