OP I just tested your sketch and it's fried my brand new Leonardo board ![]()
Looks like I've got the same LCD keypad shield as you. I brought it ages ago here Recommendations For You - DealeXtreme Mine doesn't say DR Robot but looks like the same shield in every other respect.
I was having problems getting it to display anything but a few solid blocks as you were initially (although my blocks were only half height for some reason). I still haven't managed to get it displaying anything (despite the pins being correct as far as I can tell). Anyway I thought I'd test if it also had the backlight issue you discovered. On running your sketch the backlight faded in and out so I concluded it didn't have the issue. I carried on trying to diagnose why the LCD wasn't displaying anything, then it stopped working completely after a few minutes. Noticed the arduino chip was super hot. Now VIN/5v and GND are dead short on arduino board (nothing else plugged into arduino)
When I tested the sketch on my older seeduino board the backlight flashed on and off indicating the shield did have the bad wiring. For whatever reason the voltage didn't droop on my Leonardo making the sketch think it was fine (and going on to fry it).
It may have been a design flaw of my Leonardo in particular as it is a cheap clone Recommendations For You - DealeXtreme
Still I just thought I'd warn anyone else of the potential danger of running the sketch.