Brightness of LCD displays with I2C - MobiFlight/MobiFlight-Connector GitHub Wiki

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.

Brightness vs. Contrast

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.

i2c

1. The jumper

When leaving the connector on the pins labeled with background brightness you will get the maximum background brightness.

LCD-Brightness-1_Jumper

2. Trimmer

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.

LCD-Brightness-2-poti

3. Photocell

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.

LCD-Brightness-3-photocell

4. PWM

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.

4.1 Module settings

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)

LCD-Brightness-4-rotary

The configuration for the PWM pin is done by adding a LED / Output device on one of the PWM capable pins of your Arduino:

LCD-pwm-module2

4.2 Input settings

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.

LCD-pwm-rotary

4.3 Output settings

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.

LCD-pwm-output-1

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

LCD-pwm-output-3

And that's how it should look like.

lcd_max lcd_mid lcd_low

4.3 Considerations

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.