Nokia 5110 problem writing variable to screen

I'm trying to encode a phone with the trio of #include <SPI.h> , #include <Adafruit_GFX.h> and #include <Adafruit_PCD8544.h>.
I defined a variable for the operator:
int opera = "BATUcell";

I'm trying to print to my NOKIA 5110 screen with display.println(opera); code.
Result: 1432

Why is this happening? Is there a solution?

You're trying to assign a nine element char array to a single int?

Please remember to use code tags when posting all of your code

You need all of code?
Aye aye!

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include "musics.h";
#include "images.h";


Adafruit_PCD8544 display = Adafruit_PCD8544(8, 9, 10, 12, 11);



int yilanpuan = 0;
int yilanx = 2;
int yilany = 12;
int menu = "menu1";
int contrast = 57;
int opera = "BATUcell";

// Space Race
int Joy_X;
int enemy_0_pos, enemy_1_pos, enemy_phase;
int game_speed = 0;
int score = 0;
char POS = 2;
boolean enemy_dead = true;
boolean control = true;

// Arduino pin numbers
const int SW_pin = 5; // digital pin connected to switch output
const int X_pin = 0; // analog pin connected to X output
const int Y_pin = 1; // analog pin connected to Y output

void setup()
{
  pinMode(buzzer, OUTPUT);
  pinMode(SW_pin, INPUT_PULLUP);
  Serial.begin(9600);
  display.begin();
  display.setContrast(contrast);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(BLACK);
  intro();
}

void loop()
{
  if (menu == "menu1") {
    menu1();
  } else if (menu == "menu2") {
    menu2();
  } else if (menu == "oyunlar1") {
    oyunlar1();
  } else if (menu == "oYilan1") {
    oYilan1();
  } else if (menu == "yilanPlay") {
    yilanPlay();
  } else if (menu == "oyunlar2") {
    oyunlar2();
  } else if (menu == "srScreen") {
    srScreen();
  } else if (menu == "oyunlar3") {
    oyunlar3();
  } else if (menu == "menu3") {
    menu3();
  } else if (menu == "calc1") {
    calc1();
  } else if (menu == "menu4") {
    menu4();
  } else if (menu == "menu5") {
    menu5();
  } else if (menu == "ayarlar1") {
    ayarlar1();
  } else if (menu == "ayarlar2") {
    ayarlar2();
  } else if (menu == "ayarlar3") {
    ayarlar3();
  } else if (menu == "aKontrast1") {
    aKontrast1();
  } else {
    Serial.println("no menu finded. try again.");
  }
  Serial.print("Switch:  ");
  Serial.print(digitalRead(SW_pin));
  Serial.print(" | ");
  Serial.print("X-axis: ");
  Serial.print(analogRead(X_pin));
  Serial.print(" | ");
  Serial.print("Y-axis: ");
  Serial.print(analogRead(Y_pin));
  Serial.println(" | ");
  delay(200);
  // Yön kontrolü
  if (analogRead(X_pin) < 200) { //Aşağı
    Serial.println("Asagi");
    if (menu == "oyunlar1") {
      menu = "oyunlar2";
    } else if (menu == "oyunlar2") {
      menu = "oyunlar3";
    } else if (menu == "ayarlar1") {
      menu = "ayarlar2";
    } else if (menu == "ayarlar2") {
      menu = "ayarlar3";
    } else if (menu == "yilanPlay") {
      while (yilany <= 83) {
        display.drawRect(0, 0, 83, 47, BLACK);
        display.fillRect(0, 0, 83, 10, BLACK);
        display.setTextColor(WHITE, BLACK);
        display.setCursor(1, 1);
        display.print("Puan: ");
        display.print(yilanpuan);
        display.display();
        display.fillRect(43, 23, 4, 4, BLACK);
        delay(25);
        display.fillRect(yilanx, yilany, 12, 4, BLACK);
        display.display();
        delay(75);
        display.clearDisplay();
        display.display();
        yilany++;
      }
    }
  } else if (analogRead(X_pin) > 800) { //Yukarı
    Serial.println("Yukari");
    if (menu == "oyunlar2") {
      menu = "oyunlar1";
    } else if (menu == "oyunlar3") {
      menu = "oyunlar2";
    } else if (menu == "ayarlar2") {
      menu = "ayarlar1";
    } else if (menu == "ayarlar3") {
      menu = "ayarlar2";
    }
  } else if (analogRead(Y_pin) < 200) { // Sol
    if (menu == "menu2") {
      menu = "menu1";
    } else if (menu == "menu3") {
      menu = "menu2";
    } else if (menu == "menu4") {
      menu = "menu3";
    } else if (menu == "menu5") {
      menu = "menu4";
    } else if (menu == "aKontrast1") {
      Serial.print("kontrastsola :");
      Serial.println(contrast);
      contrast--;
      display.setContrast(contrast);
    }
  } else if (analogRead(Y_pin) > 800) { // Sağ
    if (menu == "menu1") {
      menu = "menu2";
    } else if (menu == "menu2") {
      menu = "menu3";
    } else if (menu == "menu3") {
      menu = "menu4";
    } else if (menu == "menu4") {
      menu = "menu5";
    } else if (menu == "aKontrast1") {
      Serial.print("kontrastsağa :");
      Serial.println(contrast);
      contrast++;
      display.setContrast(contrast);
    }
  } else {
    Serial.println("nope");
  }
}


// Graphics
void intro() {
  display.drawBitmap(0, 0,  logofavlogo, 84, 37, BLACK);
  display.setCursor(20, 27);
  display.setTextSize(1);
  display.print("Phone V1");
  display.drawBitmap(0, 29, atbcreatedby, 84, 22, BLACK);
  display.display();
  delay(200);
  music("nokia");
  display.clearDisplay();
}

void menu1() {
  display.setTextSize(1);
  display.clearDisplay();
  display.setCursor(1, 1);
  display.println(opera);
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setTextSize(1);
  display.setCursor(23, 40);
  display.println("Telefon");
  display.drawBitmap(28, 11,  logo_phone, 40, 39, BLACK);
  display.drawBitmap(73, 20, logonext, 10, 10, BLACK);
  display.display();
  display.setTextColor(BLACK);
}

void menu2() {
  display.setTextSize(1);
  display.clearDisplay();
  display.setCursor(1, 1);
  display.println(opera);
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setTextSize(1);
  display.setCursor(23, 40);
  display.println("Oyunlar");
  display.drawBitmap(0, 20, logoback, 10, 10, BLACK);
  display.drawBitmap(28, 11,  logo_games, 30, 30, BLACK);
  display.drawBitmap(73, 20, logonext, 10, 10, BLACK);
  display.display();
  display.setTextColor(BLACK);
  if (digitalRead(SW_pin) == 0) {
    Serial.println("goto Oyunlar");
    menu = "oyunlar1";
  }
}

void oyunlar1() {
  display.setTextSize(1);
  display.clearDisplay();
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setCursor(1, 1);
  display.println(opera);
  display.display();
  display.setTextColor(BLACK);
  display.setRotation(1);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("Oyunlar");
  display.display();
  display.setRotation(0);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(8, 11);
  display.print(" > Yilan ");
  display.display();
  display.setTextColor(BLACK);
  display.setCursor(8, 21);
  display.print("> Space Race ");
  display.setCursor(8, 31);
  display.print("> Cikis ");
  display.display();
  if (digitalRead(SW_pin) == 0) {
    menu = "oYilan1";
  }
}

void oYilan1() {
  display.setTextSize(1);
  display.clearDisplay();
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setCursor(1, 1);
  display.println(opera);
  display.display();
  display.setTextColor(BLACK);
  display.setRotation(1);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("Yilan");
  display.display();
  display.setRotation(0);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(8, 11);
  display.print("> Oyna ");
  display.display();
  display.setTextColor(BLACK);
  display.setCursor(8, 21);
  display.print("> Rekor ");
  display.display();
  if (digitalRead(SW_pin) == 0) {
    menu = "yilanPlay";
  }
}

void yilanPlay() {
  display.clearDisplay();
  display.drawRect(0, 0, 83, 47, BLACK);
  display.fillRect(0, 0, 83, 10, BLACK);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(1, 1);
  display.print("Puan: ");
  display.print(yilanpuan);
  display.display();

  display.fillRect(43, 23, 4, 4, BLACK);
  delay(25);
  display.fillRect(yilanx, yilany, 12, 4, BLACK);
  display.display();
  yilanx++;
  delay(50);
  yilanx = yilanx;
  if (analogRead(X_pin) < 200) {
    delay(25);
    display.fillRect(yilany, yilanx, 12, 4, BLACK);
    display.display();
    yilany++;
    delay(50);
    yilany = yilany;
  }
  if (analogRead(Y_pin) > 800) {
    delay(25);
    display.fillRect(yilanx, yilany, 12, 4, BLACK);
    display.display();
    yilanx++;
    delay(50);
    yilanx = yilanx;
  }
  if (yilanx == 47) {
    yilanx = 2;
  }
  if (yilany == 83) {
    yilany = 12;
  }
}

void oyunlar2() {
  display.setTextColor(BLACK);
  display.setTextSize(1);
  display.clearDisplay();
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setCursor(1, 1);
  display.println(opera);
  display.display();
  display.setTextColor(BLACK);
  display.setRotation(1);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("Oyunlar");
  display.display();
  display.setRotation(0);
  display.setCursor(8, 11);
  display.print("> Yilan ");
  display.display();
  display.setTextColor(WHITE, BLACK);
  display.setCursor(8, 21);
  display.print(" > Space... ");
  display.display();
  display.setTextColor(BLACK);
  display.setCursor(8, 31);
  display.print("> Cikis ");
  display.display();
  if (digitalRead(SW_pin) == 0) {
    menu = "srScreen";
  }
}

void srScreen() {
  display.clearDisplay();


  //Draw the Border for Screen
  display.drawLine(0, 0, 0, 47, BLACK);
  display.drawLine(50, 0, 50, 47, BLACK);
  display.drawLine(0, 47, 50, 47, BLACK);

  //Enter Default Texts
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(52, 2);
  display.println("HIZ");
  display.setCursor(54, 12);
  display.println(game_speed);
  display.setCursor(52, 25);
  display.println("PUAN");
  display.setCursor(54, 35);
  display.println(score);
  display.display();

  //Get input from user
  Joy_X = analogRead(Y_pin); //Read the X vaue from Joystick
  if (Joy_X < 312 && POS != 1 && control == true) //If joy stick moves right
  {
    POS--;  //Decrement position of spaceship
    control = false;
  }
  else if (Joy_X > 712 && POS != 3 && control == true) //If joy stick moves right
  {
    POS++;  //Increment position of spaceship
    control = false;
  }
  else if (Joy_X > 502 && Joy_X < 522) //If joystick back to initial position
    control = true; //Preare it for next move
  //Input from user received



  player_car(POS); //Place the Space ship based on the input from user

  if (enemy_dead) //Check of enemy ships are dead
  { //If they are dead
    enemy_0_pos = POS; //create first enemy above the space ship
    enemy_1_pos = random(0, 4); //create secound enemy at some other random place
    enemy_phase = 0; //Bring the enemy form the top
    enemy_dead = false; //Enem   y is created so they are not dead anymore
  }

  enemy_ship (enemy_0_pos, enemy_phase); enemy_phase++; //Place the first enemy on screen and drive him down
  enemy_ship (enemy_1_pos, enemy_phase); enemy_phase++; //Place the secound enemy on screen and drive him down

  if (enemy_phase > 22 && ((enemy_0_pos == POS) || (enemy_1_pos == POS)) ) //If the Spaceship touches any one of the enemy
    game_over(); //Display game over

  if (enemy_phase > 40) //If thespace ship escapes the enemys
  {
    enemy_dead = true;  //Increase the score and kill the enemys
    score++;
  }

  Level_Controller(); //BAsed on score increase the speed of game


  display.display();  //Update the display with all the changes made so far
}


void   Level_Controller() //Increase the speed of game based on the score.
{
  if (score >= 0 && score <= 5) //If score 0-5
  {
    game_speed = 0; delay(70); //slow the game by 70ms
  }
  if (score > 5 && score <= 10) //If score 5-10
  {
    game_speed = 1; delay(60); //slow the game by 60ms
  }
  if (score > 10 && score <= 15) //If score 10-15
  {
    game_speed = 2; delay(50); //slow the game by 50ms
  }
  if (score > 15 && score <= 20) //If score 15-20
  {
    game_speed = 3; delay(40); //slow the game by 40ms
  }
  if (score > 20 && score <= 25) //If score 20-25
  {
    game_speed = 4; delay(30); //slow the game by 30ms
  }
  if (score > 25 && score <= 30) //If score 25-30
  {
    game_speed = 5; delay(20); //slow the game by 20ms
  }
  if (score > 30 && score <= 35) //If score 30-35
  {
    game_speed = 6; delay(10); //slow the game by 10ms
  }
  if (score > 35 && score <= 40) //If score 35-40
  {
    game_speed = 7; delay(5); //slow the game by 5ms
  }
  if (score > 40 && score <= 45) //If score 40-45
  {
    game_speed = 8; delay(25); //slow the game by 25ms
  }
  if (score > 45 && score <= 50) //If score 45-50
  {
    game_speed = 9; delay(125); //slow the game by 125ms
  }
  if (score > 50 && score <= 55) //If score 50-55
  {
    game_speed = 10; delay(1); //slow the game by 1ms
  }
}

void enemy_ship(int place, int phase) //Place the enemy_ship in the new place and phase
{
  if (place == 1)
    display.drawBitmap(2, phase, enemy, 15, 15, BLACK);

  if (place == 2)
    display.drawBitmap(18, phase, enemy, 15, 15, BLACK);

  if (place == 3)
    display.drawBitmap(34, phase, enemy, 15, 15, BLACK);
}

void game_over() //Display game over screen
{
  display.clearDisplay();
  display.setTextColor(BLACK);
  display.setCursor(20, 2);
  display.setTextSize(2);
  display.println("OYUN  BiTTi!");
  display.display();
  display.setTextSize(1);
  display.setCursor(0, 31);
  display.println("5sn bekleyin");
  display.setTextColor(WHITE, BLACK);
  display.println(" > Geri ");
  display.display();
  if (digitalRead(SW_pin) == 0) {
    menu = "oyunlar2";
  }
}

void player_car(char pos) //Place the spaceship based on the user selected position
{
  if (pos == 1)
    display.drawBitmap(2, 32, ship, 15, 15, BLACK);

  if (pos == 2)
    display.drawBitmap(18, 32, ship, 15, 15, BLACK);

  if (pos == 3)
    display.drawBitmap(34, 32, ship, 15, 15, BLACK);
}


void oyunlar3() {
  display.setTextColor(BLACK);
  display.setTextSize(1);
  display.clearDisplay();
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setCursor(1, 1);
  display.println(opera);
  display.display();
  display.setTextColor(BLACK);
  display.setRotation(1);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("Oyunlar");
  display.display();
  display.setRotation(0);
  display.setCursor(8, 11);
  display.print("> Yilan ");
  display.display();
  display.setCursor(8, 21);
  display.print("> Space Race ");
  display.display();
  display.setTextColor(WHITE, BLACK);
  display.setCursor(8, 31);
  display.print(" > Cikis ");
  display.display();
  if (digitalRead(SW_pin) == 0) {
    menu = "menu2";
  }
}


void menu3() {
  display.setTextSize(1);
  display.clearDisplay();
  display.setCursor(1, 1);
  display.println(opera);
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setTextSize(1);
  display.setCursor(0, 40);
  display.println("Hesap Makinesi");
  display.drawBitmap(0, 20, logoback, 10, 10, BLACK);
  display.drawBitmap(28, 11,  logo_calc, 30, 30, BLACK);
  display.drawBitmap(73, 20, logonext, 10, 10, BLACK);
  display.display();
  display.setTextColor(BLACK);
  if (digitalRead(SW_pin) == 0) {
    menu = "calc1";
  }
}

void calc1() {
  display.setTextSize(1);
  display.clearDisplay();
  display.setCursor(1, 1);
  display.println(opera);
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setTextSize(1);
  display.drawRect(0, 23, 83, 1, BLACK);
  display.display();
  display.setTextColor(BLACK);
}

void menu4() {
  display.setTextSize(1);
  display.clearDisplay();
  display.setCursor(1, 1);
  display.println(opera);
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setTextSize(1);
  display.setCursor(33, 40);
  display.println("Saat");
  display.drawBitmap(0, 20, logoback, 10, 10, BLACK);
  display.drawBitmap(28, 11,  logo_clock, 30, 30, BLACK);
  display.drawBitmap(73, 20, logonext, 10, 10, BLACK);
  display.display();
  display.setTextColor(BLACK);
}

void menu5() {
  display.setTextSize(1);
  display.clearDisplay();
  display.setCursor(1, 1);
  display.println(opera);
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setTextSize(1);
  display.setCursor(23, 40);
  display.println("Ayarlar");
  display.drawBitmap(0, 20, logoback, 10, 10, BLACK);
  display.drawBitmap(28, 11,  logo_settings, 30, 30, BLACK);
  display.display();
  display.setTextColor(BLACK);
  if (digitalRead(SW_pin) == 0) {
    Serial.println("goto Ayarlar");
    menu = "ayarlar1";
  }
}


void ayarlar1() {
  display.setTextSize(1);
  display.clearDisplay();
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setCursor(1, 1);
  display.println(opera);
  display.display();
  display.setTextColor(BLACK);
  display.setRotation(1);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("Ayarlar");
  display.display();
  display.setRotation(0);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(8, 11);
  display.print(" > Kontrast ");
  display.display();
  display.setTextColor(BLACK);
  display.setCursor(8, 21);
  display.print("> Zil Sesi ");
  display.setCursor(8, 31);
  display.print("> Cikis");
  display.display();
  display.setTextColor(BLACK);
  if (digitalRead(SW_pin) == 0) {
    menu = "aKontrast1";
  }
}
void aKontrast1() {
  display.setTextSize(1);
  display.clearDisplay();
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setTextColor(BLACK);
  display.setCursor(1, 1);
  display.println(opera);
  display.display();
  display.setTextColor(BLACK);
  display.setCursor(0, 11);
  display.print("Kontrast: ");
  display.println(contrast);
  display.display();
  display.setCursor(0, 21);
  display.print("Ayarlamak icin sag-sol yapin");
  display.setTextColor(WHITE, BLACK);
  display.setCursor(0, 41);
  display.print(" > Ayarladim ");
  display.display();
  if (digitalRead(SW_pin) == 0) {
    menu = "ayarlar1";
  }
}

void ayarlar2() {
  display.setTextSize(1);
  display.clearDisplay();
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setCursor(1, 1);
  display.println(opera);
  display.display();
  display.setTextColor(BLACK);
  display.setRotation(1);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("Ayarlar");
  display.display();
  display.setRotation(0);
  display.setCursor(8, 11);
  display.print("> Kontrast ");
  display.setTextColor(WHITE, BLACK);
  display.setCursor(8, 21);
  display.print(" > Zil Sesi ");
  display.display();
  display.setTextColor(BLACK);
  display.setCursor(8, 31);
  display.print("> Cikis");
  display.display();
}

void ayarlar3() {
  display.setTextColor(BLACK);
  display.setTextSize(1);
  display.clearDisplay();
  display.fillRect(0, 9, 83, 1, BLACK);
  display.display();
  display.setCursor(1, 1);
  display.println(opera);
  display.display();
  display.setTextColor(BLACK);
  display.setRotation(1);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("Ayarlar");
  display.display();
  display.setRotation(0);
  display.setCursor(8, 11);
  display.print("> Kontrast ");
  display.setCursor(8, 21);
  display.print("> Zil Sesi ");
  display.display();
  display.setTextColor(WHITE, BLACK);
  display.setCursor(8, 31);
  display.print(" > Cikis");
  display.display();
  if (digitalRead(SW_pin) == 0) {
    menu = "menu4";
  }
}

Code is Turkish LOL :slight_smile:

And there's another.
(Though "only" six elements this time).

I don't really know how you got so much code without testing it to find this pretty fundamental error.

But there is no error in my project.
The Arduino IDE did not throw any errors.
I just couldn't figure out that variable part (int opera = "BATUcell";).

Edit: And i have Turkish brain!
Edit 2: By the way, these are not the only codes. I have two more pages.

If you mean that the compiler did not report an error, then you are probably correct, but that does not mean that the code is correct, just that all of the commands have the correct syntax

An int variable can hold a value between -32,768 and 32,767 on most Arduinos. (see int - Arduino Reference) It cannot hold a string of characters, which is what your program tries to do

Start small. Can you print a string of characters to the display ? Post the smallest sketch that does this then you can move on to putting the string in a variable and applying it to your main sketch

I'm a little surprised there are no errors, but there will certainly be warnings.

Ye-ee-ah!

And there's the sketc- no this is just image.


with blur effect (i don't create this effect, the camera is created this effect...

Image:
1432 on/in corner of the screen (IT'S MEANS BATUcell)
A phone icon
"Telefon" text under the phone icon

The warning:

Çalışmanız programın 24928 bayt (81 %) saklama alanını kullandı. Maksimum 30720 bayt.
Global değişkenler belleğin 1535 byte kadarını  (74%) kullanıyor. Yerel değişkenler için 513 byte yer kalıyor. En fazla 2048 byte kullanılabilir.

and i translated it to English..

Your work used 24928 bytes (81%) of the program's storage. Maximum of 30720 bytes.
Global variables use up to 1535 bytes (74%) of memory. That leaves 513 bytes of space for local variables. A maximum of 2048 bytes can be used.

Anyone have a solution :interrobang:

You need to change all of your code to use C strings and strcmp.

It's a complete rewrite

But this is not solution for me :no_mouth:

How was that printed ?
Post a complete sketch that just prints that

Write a parser that will automatically rewrite your program to work.

Easy. There is a int opera = "BATUcell"; code.
Little display.println(opera); ...
And BOOOOM!!! 1432 is printed

As I said

This is the sketch.

Oh. I failed again.

Ok.

Good luck.

You did. What part of complete sketch do you not understand ?

You could have looked it up, but this discussion is getting ridiculous. Try

char opera[] = "BATUcell";