Page 1 of 1

Set cursor command not working (i2c) Arduino

Posted: Mon Jun 24, 2013 3:36 pm
by Vtech
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);

}




Re: Set cursor command not working (i2c) Arduino

Posted: Mon Jun 24, 2013 4:12 pm
by Clark
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

Re: Set cursor command not working (i2c) Arduino

Posted: Tue Jun 25, 2013 11:13 am
by Vtech
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

Re: Set cursor command not working (i2c) Arduino

Posted: Tue Jun 25, 2013 11:30 am
by Clark
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

Re: Set cursor command not working (i2c) Arduino

Posted: Tue Jun 25, 2013 11:56 am
by Vtech
Thank Troy for the information.
its much appreciated

Thank you again.

And Great service by the way.

Pierre-Luc

Re: Set cursor command not working (i2c) Arduino

Posted: Tue Jun 25, 2013 1:38 pm
by Clark
Not a problem Pierre-Luc,
Troy