Atmega8 and Nokia 5110 LCD

The 5110 LCD is a graphical 84×48 pixels monochrome display.
It features a modest Backlight illumination, that can be blue or white. It only needs 3V to run, and it is 5V signal tolerant (not the backlight, so be careful, the leds need 3V max!) Its cost is also low, making it an excellent choice for DIY projects.
nokia_5110_lcd_atmega_1 nokia_5110_lcd_atmega_2

To connect it to an Atmega8, you can use the following diagram:
atmega8_nokia5110

The code, written as a C++ class, allows you to output text or draw pixels, position anywhere on the screen, or even draw images. The initialization function is highly flexible, allowing you to specify the pins allocated for the LCD, on the fly:

// define the 5 LCD Data pins: SCE, RST, DC, DATA, CLK
lcd.lcd_init(&PORTB, PB0, &PORTB, PB1, &PORTB, PB2, &PORTB, PB3, &PORTB, PB4);
    
while (1) {
	// image demo
	lcd.printPictureOnLCD(introScreen);
	_delay_ms(2000);
	lcd.lcd_clear();
	
	// goto and char demo
	for (int i=0;i<14;i++)
		for (int j=0;j<6;j++) {
			lcd.lcd_goto_xy(i,j);
			lcd.lcd_chr('0' + (i + j) % 10);
			_delay_ms(10);
		}
	_delay_ms(2000);
	lcd.lcd_clear();
	
	// formatted string demo
	for (int i=10;i>0;i--) {
		lcd.lcd_goto_xy(0,1);
		lcd.lcd_string_format("   00.00.%02d   \n  pocketmagic \n     .net     ", i);
		_delay_ms(200);
	}
	_delay_ms(2000);
	lcd.lcd_clear();
	
	// draw a chart
	for (int i=0;i<84;i++) {
		int f = (i * i) % 48;
		lcd.drawPixel(i,0, 1);
		lcd.drawPixel(i, f, 1);
	}
	_delay_ms(2000);
	lcd.lcd_clear();
}	

Here is the result of the code above:

A few pictures:
nokia_5110_lcd_atmega_3 nokia_5110_lcd_atmega_4 nokia_5110_lcd_atmega_5

The image data with the two cats, available in introscreen.h, has been generated out of a monochrome, 84x48 pixels BMP, using the LCDAssistant software, by Radoslaw Kwiecien.
assistant

The code is available as open source, licensed under GPL v2:
lcd_5110

This article has 12 Comments

  1. i’m newbie here, and idk how to use your code into avr studio.. i mean did i make a new project? or add the header etc..

    i never use header or cpp file before maybe you can direct me to another basic tutorial link

  2. @Radu

    Just ordinary C, that would ensure great project compatibility. I have 2 of those displays and all I can find are arduino libraries (arduino is for babies!) or just really poor GCC libraries. 😛

  3. If I only had the knowledge to do it, there is so much to learn 🙂

    Great job on your projects by the way!

Leave a Reply