nokia 5110

Hi
I trying to change LCD 16x2 to nokia 5110,
The program displays i and j on serial monitor and on LCD 16x2.
How to make the numbers to be displayed on nokia 5110 ?

//#include <LiquidCrystal.h>
#include <EEPROM.h>
//LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
//LiquidCrystal lcd(PB15, PB5, PA2, PB6, PB8, PB9);

//////////////////
#include <LCD5110_Graph.h> // THE LIBRARY I AM USING IS THIS:  http://www.rinkydinkelectronics.com/library.php?id=47
LCD5110 lcd(PA0, PA1, PA2, PA4, PA3);

extern unsigned char BigNumbers[];
extern uint8_t ui[];
extern uint8_t startScreen[];
/////////////////

int i;
int j;
void setup() {
  ///////////
  Serial.begin(115200);

  lcd.InitLCD();
  lcd.update();
  lcd.setFont(BigNumbers);
  //////////

  pinMode(PB14, INPUT_PULLDOWN);//
  pinMode(PB12, INPUT_PULLDOWN);//
  pinMode(PB13, INPUT_PULLDOWN);
  pinMode(PB15, INPUT_PULLDOWN);

  //lcd.begin(16, 2);
  //EEPROM.read(500, (uint16*)&i);
}
void loop() {

  if (digitalRead(PB13) == HIGH)
  {
    if (i < 2000) //limit

    {
      i++;
    }
  }

  if (digitalRead(PB15) == HIGH)

  {
    if (i > 0)
    {
      i--;
    }
  }

  if (digitalRead(PB14) == HIGH)
  {
    if (j < 3000) //limit
      // if (i < 25)
    {
      j++;

    }
  }

  if (digitalRead(PB12) == HIGH)
  {
    if (j > 0)
    {
      j--;

    }
  }
  //////////////////
  Serial.print(i);
  Serial.print(" ");
  Serial.println(j);

  lcd.print(i, 0, 10);
  lcd.print(i, 0, 30);

  /////////////////
  /*
    lcd.setCursor(0, 0);
    lcd.print("i=");
    lcd.print(i);
    lcd.setCursor(0, 1);
    lcd.print("j=");
    lcd.print(j);
  */
}

The 5110 displays are totally different from a hd44780 character display (1602, 2004).

Install the Adafruit_PCD8544-Nokia-5110-LCD library. The library is available through the IDE library manager. The library comes with example code to test the display.

To do graphics install the Adafruit_GFX library.

The 5110 displays are not 5V. They need 3.3V power and the inputs need 3.3V. So with a 5V Arduino you will need levels shifters on all the 5110 inputs.

Here is a good tutorial from Adafruit.

I downloaded it and this testing program is working, so display is connected correctly

#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

boolean backlight = true;
int contrast=50;

int menuitem = 1;
int page = 1;

volatile boolean up = false;
volatile boolean down = false;
volatile boolean middle = false;

int downButtonState = 0;
int upButtonState = 0;  
int selectButtonState = 0;          
int lastDownButtonState = 0;
int lastSelectButtonState = 0;
int lastUpButtonState = 0;

//Adafruit_PCD8544 display = Adafruit_PCD8544( 5, 4, 3);
Adafruit_PCD8544 display = Adafruit_PCD8544(PA0, PA1, PA2, PA3, PA4);
//#include <LCD5110_Graph.h> // THE LIBRARY I AM USING IS THIS:  http://www.rinkydinkelectronics.com/library.php?id=47
//CD5110 display(PA0, PA1, PA2, PA4, PA3);
void setup() {

  pinMode(2, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(0, INPUT_PULLUP);
  pinMode(7,OUTPUT);

  digitalWrite(7,LOW); //Turn Backlight ON
  
  Serial.begin(115200);
  
  display.begin();      
  display.setContrast(contrast); //Set contrast to 50
  display.clearDisplay(); 
  display.display();   
}

void loop() {
  
  drawMenu();

  downButtonState = digitalRead(2);
  selectButtonState = digitalRead(1);
  upButtonState =   digitalRead(0);
 
  checkIfDownButtonIsPressed();
  checkIfUpButtonIsPressed();
  checkIfSelectButtonIsPressed();

  if (up && page == 1 ) {
    up = false;
    menuitem--;
    if (menuitem==0)
    {
      menuitem=3;
    }      
  }else if (up && page == 2 ) {
    up = false;
    contrast--;
    setContrast();
  }


  if (down && page == 1) {
    down = false;
    menuitem++;
    if (menuitem==4) 
    {
      menuitem=1;
    }      
  }else if (down && page == 2 ) {
    down = false;
    contrast++;
    setContrast();
  }


  if (middle) {
    middle = false;
    
    if (page == 1 && menuitem==2) 
    {
      if (backlight) 
      {
        backlight = false;
        turnBacklightOff();
        }
      else 
      {
        backlight = true; 
        turnBacklightOn();
       }
    }

    if(page == 1 && menuitem ==3)
    {
      resetDefaults();
    }


else if (page == 1 && menuitem==1) {
      page=2;
     }
else if (page == 2) {
      page=1;
     }
   }
   
  }

  void checkIfDownButtonIsPressed()
  {
    if (downButtonState != lastDownButtonState) 
  {
    if (downButtonState == 0) 
    {
      down=true;
    }
    delay(50);
  }
   lastDownButtonState = downButtonState;
  }

void checkIfUpButtonIsPressed()
{
  if (upButtonState != lastUpButtonState) 
  {
    if (upButtonState == 0) {
      up=true;
    }
    delay(50);
  }
   lastUpButtonState = upButtonState;
}

void checkIfSelectButtonIsPressed()
{
   if (selectButtonState != lastSelectButtonState) 
  {
    if (selectButtonState == 0) {
      middle=true;
    }
    delay(50);
  }
   lastSelectButtonState = selectButtonState;
}

  
  void drawMenu()
  {
    
  if (page==1) 
  {    
    display.setTextSize(1);
    display.clearDisplay();
    display.setTextColor(BLACK, WHITE);
    display.setCursor(15, 0);
    display.print("MAIN MENU");
    display.drawFastHLine(0,10,83,BLACK);
    display.setCursor(0, 15);
   
    if (menuitem==1) 
    { 
      display.setTextColor(WHITE, BLACK);
    }
    else 
    {
      display.setTextColor(BLACK, WHITE);
    }
    display.print(">Contrast");
    display.setCursor(0, 25);
   
    if (menuitem==2) 
    {
      display.setTextColor(WHITE, BLACK);
    }
    else 
    {
      display.setTextColor(BLACK, WHITE);
    }    
    display.print(">Light: ");
    
    if (backlight) 
    {
      display.print("ON");
    }
    else 
    {
      display.print("OFF");
    }
    display.display();
    
    if (menuitem==3) 
    { 
      display.setTextColor(WHITE, BLACK);
    }
    else 
    {
      display.setTextColor(BLACK, WHITE);
    }  
    display.setCursor(0, 35);
    display.print(">Reset");
    display.display();
  }
    
 
  else if (page==2) 
  {
    
    display.setTextSize(1);
    display.clearDisplay();
    display.setTextColor(BLACK, WHITE);
    display.setCursor(15, 0);
    display.print("CONTRAST");
    display.drawFastHLine(0,10,83,BLACK);
    display.setCursor(5, 15);
    display.print("Value");
    display.setTextSize(2);
    display.setCursor(5, 25);
    display.print(contrast);
 
    display.setTextSize(2);
    display.display();
  }
  
  }

  void resetDefaults()
  {
    contrast = 50;
    setContrast();
    backlight = true;
    turnBacklightOn();
  }

  void setContrast()
  {
    display.setContrast(contrast);
    display.display();
  }

  void turnBacklightOn()
  {
    digitalWrite(7,LOW);
  }

    void turnBacklightOff()
  {
    digitalWrite(7,HIGH);
  }

but program LCD 16x2 converted to nokia is not = blank screen

//#include <LiquidCrystal.h>
//#include <EEPROM.h>
//LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
//LiquidCrystal lcd(PB15, PB5, PA2, PB6, PB8, PB9);

//////////////////
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

Adafruit_PCD8544 display = Adafruit_PCD8544(PA0, PA1, PA2, PA3, PA4);

int contrast=50;
int i;
int j;
void setup() {
  ///////////
  Serial.begin(115200);

  //////////
 display.begin();      
  display.setContrast(contrast); //Set contrast to 50
  display.clearDisplay(); 
  display.display();   
  //////////

  pinMode(PB14, INPUT_PULLDOWN);//
  pinMode(PB12, INPUT_PULLDOWN);//
  pinMode(PB13, INPUT_PULLDOWN);
  pinMode(PB15, INPUT_PULLDOWN);

  //lcd.begin(16, 2);

  //EEPROM.read(500, (uint16*)&i);
}
void loop() {

  if (digitalRead(PB13) == HIGH)
  {
    if (i < 2000) //limit

    {
      i++;
    }
  }

  if (digitalRead(PB15) == HIGH)

  {
    if (i > 0)
    {
      i--;
    }
  }

  if (digitalRead(PB14) == HIGH)
  {
    if (j < 3000) //limit
      // if (i < 25)
    {
      j++;

    }
  }

  if (digitalRead(PB12) == HIGH)
  {
    if (j > 0)
    {
      j--;

    }
  }
  //////////////////
  Serial.print(i);
  Serial.print(" ");
  Serial.println(j);

  // lcd.print(i, 0, 10);
  //lcd.print(i, 0, 10);

  display.setTextSize(2);
  display.setCursor(5, 25);
  display.print(i);

  /////////////////
  /*
    lcd.setCursor(0, 0);
    lcd.print("i=");
    lcd.print(i);
    lcd.setCursor(0, 1);
    lcd.print("j=");
    lcd.print(j);
  */
}
  display.setTextSize(2);
  display.setCursor(5, 25);
  display.print(i);

That code sets up the display buffer.

display.display();

Sends the buffer to the display. You must call display.display(); for anything to show on the screen or after you call display.clearDisplay(); to clear the screen.

after uploading the 0 appears = display.print(i); for i = 0, then if i is higher then 0 I have a small black rectangle.

I was trying to use display.clearDisplay(); , but didn't work

//#include <LiquidCrystal.h>
//#include <EEPROM.h>
//LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
//LiquidCrystal lcd(PB15, PB5, PA2, PB6, PB8, PB9);

//////////////////
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

Adafruit_PCD8544 display = Adafruit_PCD8544(PA0, PA1, PA2, PA3, PA4);

int contrast = 60;
int i;
int j;
void setup() {
  ///////////
  Serial.begin(115200);

  //////////
  display.begin();
  display.setContrast(contrast); //Set contrast to 50
  display.clearDisplay();
  // display.display();
  //////////

  pinMode(PB14, INPUT_PULLDOWN);//
  pinMode(PB12, INPUT_PULLDOWN);//
  pinMode(PB13, INPUT_PULLDOWN);
  pinMode(PB15, INPUT_PULLDOWN);

  //lcd.begin(16, 2);

  //EEPROM.read(500, (uint16*)&i);
}
void loop() {

  if (digitalRead(PB13) == HIGH)
  {
    if (i < 2000) //limit

    {
      i++;
    }
  }

  if (digitalRead(PB15) == HIGH)

  {
    if (i > 0)
    {
      i--;
    }
  }

  if (digitalRead(PB14) == HIGH)
  {
    if (j < 3000) //limit
      // if (i < 25)
    {
      j++;

    }
  }

  if (digitalRead(PB12) == HIGH)
  {
    if (j > 0)
    {
      j--;

    }
  }
  //////////////////
  Serial.print(i);
  Serial.print(" ");
  Serial.println(j);

  // display.clearDisplay();
  display.setTextSize(2);
  display.setCursor(5, 25);
  display.display();
  display.print(i);

}

I did it,
Thank You

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.