DFrobot back-light control

HI I have this LCD...
https://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)

It says on the site that Pin 10 is backlight control.

but then in the example sketch there is no mention of pin 10

// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

so my question is...

Can I control this with rotary encoder and pwm ?

Even though the provided sketches do not deal with the backlight it is still connected to pin 10. This means:

  • if you do want to control the backlight you will have to use pin 10.
  • you probably shouldn't tie anything else to pin 10 since the backlight circuitry may interfere with it.

Don

1 Like

Thanks so much, so I have tested LCD and the LED backlight is on by default when I ground pin 10 it goes off!

So looks like I'm good to dim via PWM, now to figure that bit out lol

many thanks

onisuk:
Thanks so much, so I have tested LCD and the LED backlight is on by default when I ground pin 10 it goes off!

So did you actually run the lcd keypad test sketch that detects if the shield has the h/w issue?
h/w that has the issue will appear to work but can damage the AVR.

If you have a backlight control h/w issue on your shield, you should not control the backlight using D10 until you fix the h/w.
Alternatiavely you can use the recommended s/w work around but you will not be able to do dimming with PWM.

If you want a library that supports backlight control, you could use my hd44780 library.
It is called hd44780 and can be found in the library manager.
The i/o class is the hd44780_pinIO
You can read more about it here:

See the included examples for header files that need to be included and the constructor use to configure the library for backlight control.

--- bill

onisuk:
Can I control this with rotary encoder and pwm ?

If you want to stay safe and don't want to risk damage to your Arduino board or the backlight transistor on the LCD Keypad Shield, you can use ON/OFF control only, but NOT PWM control.

Backlight is ON when pin-10 pinMode is INPUT and LOW state
Cacklight is OFF when pin-10 pinMode is OUTPUT and LOW state

Here are two functions to control backlight of LCD Keypad Shield and staying "safe":

const byte BACKLIGHTPIN=10;

void backlightOff()
{
  digitalWrite(BACKLIGHTPIN, LOW);
  pinMode(BACKLIGHTPIN, OUTPUT);
}

void backlightOn()
{
  digitalWrite(BACKLIGHTPIN, LOW);
  pinMode(BACKLIGHTPIN, INPUT);

Perhaps you can create a few "brigthness steps, let's say 4 steps:
25% brightness
50% brightness
75% brightness
100% brightness
by switching backlight ON/OFF fast, using a hardware TIMER and a timer interrupt routine.
This would require one otherwise unused hardware timer like TIMER1 or TIMER2. TIMER0 is used by default in the Arduino core library to establish millis() and micros() and delay() functions.

jurs:
If you want to stay safe and don't want to risk damage to your Arduino board or the backlight transistor on the LCD Keypad Shield, you can use ON/OFF control only, but NOT PWM control.

It depends on the shield. Not all the shields have the backlight circuit problem.
The lcd keypad test sketch will indicate whether or not the shield has the issue.
--- bill