Serial and nokia 5110

how to read "menu" or "clear" from com3 (arduino uno) with nokia 5110 (i need vb6 code too)

#include <LCD5110_Graph.h>

LCD5110 myGLCD(8, 9, 10, 11, 12);
extern uint8_t menu[];
int incomingByte = 0; // for incoming serial data

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  
  myGLCD.InitLCD();
}

void loop() {
  // reply only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte);
    // say what you got:
if (incomingByte = ("Menu"))
{
  myGLCD.drawBitmap(0, 0, menu, 84, 48);
  myGLCD.update();
}
if (incomingByte = ("Clear"))
{
  myGLCD.clear
  myGLCD.update();
}
  }
}

you are reading a byte and then attempting to use it as a string
read a string and the use that as the command, e.g.


void setup() {
  Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
}

void loop() {
  // reply only when you receive data:
  if (Serial.available() > 0) {
    // read the incomingstring
    String s = Serial.readStringUntil('\n');
    // say what you got:
    Serial.print("I received: ");
    Serial.println(s);
    // say what you got:
    if (s.startsWith("Menu")) {
      Serial.println("   menu command");
    }
   }
}

a run gave

I received: Menu
   menu command
I received: hello
I received: Menu
   menu command

what is the Nokia and VB6 code doing? why VB6?

or if you want something non blocking I would suggest to study Serial Input Basics to handle this

@horace your code worked but not with Nokia 5110 LCD

your error report is rather vauge - what did not work?
upload your latest code indicating what does not work
if you have a simple program just writing to the LCD does it work OK?
what is the VB6 suposed to do? are you using Visual Studio?
Edit: what Arduino are you using ?

if I run a version of the code of post #2 which writes to an LCD

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3f,16,2); // set the LCD address to 0x3f

void setup(){
   lcd.init();
   lcd.backlight();
   Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
   lcd.print("enter command");
}

void loop() {
  // reply only when you receive data:
  if (Serial.available() > 0) {
    // read the incomingstring
    String s = Serial.readStringUntil('\n');
    // say what you got:
    Serial.print("I received: ");
    Serial.println(s);
    // say what you got:
    if (s.startsWith("Menu")) {
      Serial.println("   menu command");
      lcd.setCursor(1,1);
      lcd.print("menu entered");
    }
   }
}

if I enter Menu it works OK

not that one, i assembled pins to nokia 5110 (im not the finder of it)
i have realy strange problems with converting LCD to nokia 5110
the codes i try never worked, example/template im using is this code (pins are same)

/*
Lezzetli Robot Tarifleri 
https://lezzetlirobottarifleri.com/nokia-5110-lcd-ile-arduino-kullanimi-4-resim-yazdirma-kontrast
*/

#include <LCD5110_Graph.h>

LCD5110 myGLCD(8, 9, 10, 11, 12);

extern uint8_t SmallFont[];
extern uint8_t arduino_logo[];

void setup()
{
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}

void loop()
{
  myGLCD.clrScr();
  myGLCD.drawBitmap(0, 0, arduino_logo, 84, 48);
  myGLCD.update();

  delay(2000);

  myGLCD.clrScr();
  myGLCD.print("Lezzetli", CENTER, 0);
  myGLCD.print("Robot", CENTER, 16);
  myGLCD.print("Tarifleri", CENTER, 40);
  delay(2000);
}

im an expert vb6 and vb .net (vs2010) programmer but i never used those COMs
(vb6 is part of vs6, so dont compare those 2 things([mod edit link remvoed]))

try a web search for nokia 5110 lcd arduino there are plenty of links including interfacing-nokia-5110-lcd-with-arduino
upload a schematic of your wiring?

What are you using to level shift the signals between the Uno and the Nokia5110?

(this is compatible with code)

you have connected the LCD pins directly to the UNO
the UNO uses 5V logic and the LCD 3.3V
tutorials on the Nokia 5110 use 10K series resistors, e.g. nokia-5110-lcd-arduino-tutorial

the code i use for view image works maybe you see wrong, i connect to 3.3 voltage nokia works great and backlights are opened and blue when i give energy
(extra question: how to make backlight green???)

I have had 5110s working for years and wired like yours except that I think you should have a resistor in the backlight supply. I believe it is 330 ohm. The Uno's 3.3v supply is very limited. The best way to make the backlight green is buy a display with a green backlight.

which resistor is 330 ohm can you send me a picture or a screenshot of the fritzing

i know as, theres multi color LEDs on sides of screen,the blue color comes from those leds as default but of to change it to green

Green blue brown is 560 ohm. You seem to be fixated on changing the colour of the existing blue LEDs, which is nonsense.

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