LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series
Moderators: Henry , Mods
Vtech
LCD?
Posts: 3 Joined: Mon Jun 24, 2013 3:29 pm
Post
by Vtech » Mon Jun 24, 2013 3:36 pm
I'm been trying to use the set cursor command in I2c with an Arduino.
The other command are working properly.
I'm not sure what i'm doing wrong
The model of the LCD is the LK204-25
Here the code for my program
Code: Select all
#include <Wire.h> //library for I2c
#include <Arduino.h>
#define LCD (0x28)
void setup() {
Wire.begin();
gpoOFF();
clearlcd();
cursorON();
}
void loop() {
displayOFF();
delay(100);
displayON();
delay(100);
setcursor(1,1);
delay(100);
Wire.beginTransmission(0x28);
Wire.write(" Hello World\n");
Wire.endTransmission();
delay(1000);
}
//Clear Screen
void clearlcd(){
Wire.beginTransmission(0x28);
Wire.write(254);
Wire.write(88);
Wire.endTransmission();
delay(1000);
}
//Display ON
void displayON(){
Wire.beginTransmission(0x28);
Wire.write(254);
Wire.write(66);
Wire.endTransmission();
delay(1000);
}
//Display OFF
void displayOFF(){
Wire.beginTransmission(0x28);
Wire.write(254);
Wire.write(70);
Wire.endTransmission();
delay(1000);
}
//Underline Cursor
void cursorON(){
Wire.beginTransmission(0x28);
Wire.write(254);
Wire.write(74);
Wire.endTransmission();
delay(1000);
}
//Go Home
void home(){
Wire.beginTransmission(0x28);
Wire.write(254);
Wire.write(72);
Wire.endTransmission();
delay(1000);
}
//Set Cursor
void setcursor(byte x, byte y){
Wire.beginTransmission(0x28);
Wire.write(254);
Wire.write(71);
Wire.write(x);
Wire.write(y);
Wire.endTransmission();
delay(1000);
}
////General Purpose Output Off
void gpoOFF(){
Wire.beginTransmission(0x28);
Wire.write(254);
Wire.write(56);
Wire.endTransmission();
delay(1000);
}
//Select transmission
void transmission(){
Wire.beginTransmission(0x28);
Wire.write(254);
Wire.write(160);
Wire.write(0);
Wire.endTransmission();
delay(1000);
}
Clark
Matrix Orbital
Posts: 881 Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:
Post
by Clark » Mon Jun 24, 2013 4:12 pm
Hi Vtech,
I appreciate the code provided and can confirm that your functions appear to be correct. Could you please set your cursor to 2, 2 then send your text string and let me know what output is observed on the display?
Thanks,
Troy
Troy Clark
Design & Development
Matrix Orbital
Vtech
LCD?
Posts: 3 Joined: Mon Jun 24, 2013 3:29 pm
Post
by Vtech » Tue Jun 25, 2013 11:13 am
Hi Troy,
Thank you for your answer.
Here what happen when I want to use the set cursor command.
I remove this part of the code before the set cursor and it work perfectly.
I don't know why but it work.
Code: Select all
displayOFF();
delay(100);
displayON();
delay(100);
Thank you Troy
Pierre-Luc
Attachments
After I remove the part of code IMG_20130625_131856.jpg (1.44 MiB) Viewed 5893 times
What happen when I want to use the set cursor command IMG_20130625_131245.jpg (1.97 MiB) Viewed 5893 times
Clark
Matrix Orbital
Posts: 881 Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:
Post
by Clark » Tue Jun 25, 2013 11:30 am
No worries Pierre-Luc,
I appreciate the additional information provided and do now see a small error in your displayOn() function. This command requires a third byte to indicate the duration of time in minutes that the backlight should stay lit. You can use a value of 0 to ensure it stays on indefinitely.
Thanks,
Troy
Troy Clark
Design & Development
Matrix Orbital
Vtech
LCD?
Posts: 3 Joined: Mon Jun 24, 2013 3:29 pm
Post
by Vtech » Tue Jun 25, 2013 11:56 am
Thank Troy for the information.
its much appreciated
Thank you again.
And Great service by the way.
Pierre-Luc
Clark
Matrix Orbital
Posts: 881 Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:
Post
by Clark » Tue Jun 25, 2013 1:38 pm
Not a problem Pierre-Luc,
Troy
Troy Clark
Design & Development
Matrix Orbital