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.
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":
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