Pages: [1]   Go Down
Author Topic: [Solved] Moving the cursor ...  (Read 684 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone !

So i'm trying to move the cursor in order to modify only one character to avoid clearing the screen at every loop.
So i read the documentation of my screen, but I don't succeed in using the set cursor command.

Here's the screen i've got :

http://www.robot-electronics.co.uk/htm/Lcd03tech.htm

I don't know how to say : set the cursor at the first line, 8th column.

I think it should begin with something like that :
Code:
Serial.write(3);


But I can't get any further ..

Thanks in advance  smiley
« Last Edit: April 24, 2012, 04:57:29 pm by Azsde » Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wasn't it considerate of them to include a few programming examples in their 'Complete Documentation'?

The 'Serial.write(3)' just tells the controller that you want to set the cursor position.  You also have to tell it exactly where you want to put the cursor.  My guess is that you have to include two more bytes after the '3' to specify the line and the column.


Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wasn't it considerate of them to include a few programming examples in their 'Complete Documentation'?

The 'Serial.write(3)' just tells the controller that you want to set the cursor position.  You also have to tell it exactly where you want to put the cursor.  My guess is that you have to include two more bytes after the '3' to specify the line and the column.


Don

I guess it was too hard for them to do that.

Anyway, so i tried with:
Code:
Serial.write(3x8x1)


But as i was suspecting, it's not compiling ^^'

Could you give me a little clue ?

I'm a noob with the Arduino for now  smiley-sweat
« Last Edit: April 24, 2012, 09:27:02 am by Azsde » Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Could you give me a little clue ?

I'm not much of a 'C' programmer but I do know that your syntax is incorrect (and you have your line and column swapped).  Perhaps something like:

Code:
Serial.write(3,1,8);

Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Could you give me a little clue ?

I'm not much of a 'C' programmer but I do know that your syntax is incorrect (and you have your line and column swapped).  Perhaps something like:

Code:
Serial.write(3,1,8);

Don

Nop, it's not working :

Code:
code_ecran_v3.cpp: In function 'void loop()':
code_ecran_v3:63: error: no matching function for call to 'HardwareSerial::write(int, int, int)'
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/HardwareSerial.h:58: note: candidates are: virtual size_t HardwareSerial::write(uint8_t)
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:50: note:                 virtual size_t Print::write(const uint8_t*, size_t)
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:49: note:                 size_t Print::write(const char*)
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4329
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


You should get your cursor positioning working in setup() before you try it in loop().

Have you considered contacting 'Robot Electronics' for some guidance?


Don
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18807
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
Serial.write(3,1,8);

More like:

Code:
byte positionMyCursor [] = { 3, 1, 8 };

Serial.write (positionMyCursor, sizeof positionMyCursor);

But I'm unsure about whether those numbers are correct.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to you two I found out:

Code:
  LCD.write(3); // Prepare the screen to receive two bytes wich will be the line and the column
  LCD.write(1); //On line one
  LCD.write(2); // On column two

Thanks  smiley-grin
Logged

Pages: [1]   Go Up
Jump to: