Electrical – Nokia 5110 backlight

lcd

I'm learning how to run a Nokia 5110 LCD (similar to this) using an atmega328p chip. I don't understand how the backlight works. If I power the LED/backlight from one of the chip pins, it turns on when I set the pin LOW, rather than HIGH. For example, with the LCD backlight connected to PB0, and using the following code:

#include <avr/io.h>
#include <util/delay.h>

int main(void){
    DDRB |= 0b00000001;
    while(1){
        PORTB |= 0b00000001;
        _delay_ms(2000);
        PORTB &= ~(0b00000001);
        _delay_ms(500);
    }
}

The backlight is off for two seconds and on for 0.5 seconds each time through the loop. I checked the voltage to confirm, and when PB0 is high (3.3V), the backlight is off, and PB0 is low (0V) when the backlight is on. If I connect the backlight directly to ground, it stays on.

The tutorials I've been reading (e.g. SparkFun and Adafruit, and yes they're for Arduino but I'm just using the atmega328p chip) clearly show the backlight being connected to a voltage supply, not ground.

My question is: is this normal, or have I got an oddball Nokia screen with the backlight wiring reversed? How should I be wiring/controlling the backlight?

EDIT:

Here's the board I'm using:

Ebay

I notice now that it lists a 'backlight control terminal', rather than a backlight VCC as in the tutorials I'm using.

Best Answer

This just means that the leds on your board (they are not integrated into the lcd itself), have their anodes connected to V+, likely though a resistor. And you control their anodes. Alternatively there is a PNP high side control transistor.

It's not uncommon to have common anode led setups. Logic is inverted, that's all.

Without knowing the specific board you have we can't confirm. The linked auction provides no schematic or usage info at all, and the LCD blocks the traces on the top side making it hard to trace as well. It doesn't seem to use a transistor. (Assuming you got the exact one pictured. Bay shops sometime substitute similar parts.)

You could unclip the lcd and take good pictures of both sides to see.

A similar version on this blog post shows that it also has an active low light control, connected directly to ground (always on). Another with active low to a gpio. So basically its just a variation on the board layout/schematic. Doesn't really change anything in the end other than the on/off logic.