Brightness of LCD displays with I2C
When buying one of these LCD displays with I²C adapter you might have asked, how to control the brightness of the display. Here are some ways to do it.
First of all you should adjust the contrast of the display. This is done using the small trimmer on the I²C adapter. Connect the display to MF, configure the LCD display as an output device and Run the configuration. You should see some test strings. Take a small screwdriver and adjust the contrast until the displayed characters have the color of your choice, but the background isn't too dark.
When leaving the connector on the pins labeled with background brightness you will get the maximum background brightness.
Pull off the connector and attach a rotary potentiometer to these pins. When turning the potentiometer you will see the background brightness changing from full dark to maximum.
If you have your fancy day you can replace the rotary potentiometer by a photocell. Doing so the brightness will change according to the envrionmental brightness.
Most interesting is using a PWM pin of the Arduino to control the background brightness. I will combine this using a rotary encoder to control the ouput of the PWM pin. But you can also use some signals of the simulator as input for the PWM pin. Keep in mind that the maximum value for a PWM pin is limited to 255.
The setup for the Arduino consists of
- LCD display on I²C pins of the Arduino (20 & 21 on the MEGA 2560 Rev3)
- The shown pin of the I²C PCB connected to one of the PWM pins (e.g. 7)
- The Rotary to control the output on the PWM using a MF variable (pins 11 to 13)
The configuration for the PWM pin is done by adding a LED / Output device on one of the PWM capable pins of your Arduino:
We do add a configuration for the rotary encoder to the Input configs page. On the Input tab we choose the action type MobiFlight - Variable. The name of the variable can be chosen here. I selected PwmBrightness. The Input settings are
-
On Left:
Max($-1, 0)
-
On Left (Fast):
Max($-5, 0)
-
On Right:
Min($+1, 255)
-
On Right (Fast):
Min($+5, 255)
These will slowly and faster increase/decrease the variable but keep it inside the limits of 0 to 255.
You should already have an output configuration for the LCD display. Now we add a new one which will send the value of the variable to the PWM pin. Create a new row, name it e.g. display-brightness and open the edit dialog.
Choose the type MobiFlight Variable and choose the variable you took for the Rotary.
On the Display tab you select the LED / Output device and enable the PWM mode. When using the rotary, the value of the variable PwmBrightness will be written to pin 7 and control the brightness of your display. When turning the rotary clockwise/couterclockwise you should see the variable changing on the Output configs
And that's how it should look like.
Controlling the variable using a rotary is one way. Another would be to combine some signals like a potentiometer for the radio brightness by your airplane and maybe to combine this with the battery master switch. In such a case you could have the variable set to 0 as long as the master battery is switched off and to control the brightness in a ranged mapped to 5 to 255 for the display brightness.
- 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
- 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
- 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