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
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");
}
}
}
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)
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]))
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.