2012/03/14

PWM Backlight Workaround for LCD Backpack

I really like the Adafruit LCD Backpack, but I've been wanting to play around with adjusting the LCD backlight brightness programatically.  After much mulling and reading of forum posts, I decided to just operate the backlight using one extra wire to a PWM pin on the Arduino.  To try and keep things tidy, I ordered some extra 3-pin terminal blocks so I could make a 6-pin block instead of the normal 5-pin block.  Just to up the stakes, I'm doing this with my brand new 20x4 LCD.
All the Bits and Pieces

First up, I broke off 15 header pins instead of 16 and soldered them into openings 1-15, leaving opening 16 empty; this is labeled "K" on my LCD.  According to the tutorial at Adafruit, this is the backlight ground connection.  I then cut a length of wire, stripped one end and soldered it through opening 16.
Backpack with Pins and Wire Soldered

I "folded" over the wire end and soldered it to the pad on the LCD.  This required a little bit of finagling with my third hand's alligator clips, but wasn't too rough.
Backlight Ground Wire Soldered to LCD

I swapped two 3-pin terminal blocks for the 2-pin and 3-pin terminal block that came with the LCD backpack
Terminal Blocks

I soldered the resulting 6-pin terminal block to the backpack with the extra pin overhanging the PCB on the side.
Terminal Block Soldered in Place

Next up was trimming the wire to fit the length of the backpack PCB and soldering it to the extra pin.  This proved to be a bit of a pain, and I ended up with the LCD in a panavise, the backpack held by the third hands, a soldering iron in one hand, and needlenose pliers in the other.  I'm sure there's an easier approach...
Backlight Ground Wire Soldered to Backpack
Finally, I soldered the regular pins in place; overall, I'm happy with the way this turned out.  I am thinking of putting some insulation on the exposed extra pin / wire end.
Finished Backpack in Place
The code I used to test this is just the Arduino Basics/Fade example sketch and Adafruit's LiquidCrystal/HelloWorld_i2c example sketch mashed together:

3 comments:

  1. Nice work, almost looks stock!

    I'm somewhat surprised the Arduino can drive the LED backlight. Perhaps this module is a bit more energy efficient, but I've seen LED modules that need 100mA to light their backlight, a fair bit more than the 40mA "absolute maximum" that an Arduino can source from a single pin.

    ReplyDelete
    Replies
    1. Thanks! :)

      From the datasheet, it looks like the backlight is drawing 180mA, so that's a fair point. I was thinking that sinking the current has a higher rating; but, going back and rereading the Arduino site, I'm seeing that it's 40mA regardless of source/sink. Seems like it might be worth adding a MOSFET or transistor to the mix. Thanks for pointing that out :).

      Delete
    2. Just a quick follow up - I used my multimeter to measure the current draw, and it looks like it's fine; the most I saw was about 33mA.

      Delete