Pages: [1]   Go Down
Author Topic: Why am I getting strange oriental characters using print.ln() function  (Read 682 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can anyone explain this?


Uploaded with ImageShack.us

Code:
#include <LiquidCrystal.h>

const int timerstart = 8;
const int timerstop = 9;
int seconds = 0;
int timerstart1 = 0;
int timerstop1 = 0;
int output = 13;
int setseconds = 10;
int on = 0;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
 
  lcd.begin(16, 2);
  pinMode(timerstart, INPUT);
  pinMode(timerstop, INPUT);
  pinMode(output, OUTPUT);
  seconds = setseconds;
}

void loop() {
  timerstart1 = digitalRead(timerstart);
  lcd.setCursor(0, 0);
  lcd.print("Time: ");
  lcd.println(seconds);
 
 if (timerstart1 == HIGH) {
  on = 1;
 }
if (timerstop1 == HIGH) {
  on = 0;
 }
if (on == 1){
 
  seconds--;
delay(1000);

}

if (seconds == -1) { 
digitalWrite(output, HIGH);
seconds = setseconds;
on = 0;
delay(1000);
digitalWrite(output, LOW);

}

}
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
lcd.println(seconds);
You don't want to send <CR> and <LF> to the display.

(They are both printable characters)
--- bill
Logged

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

Code:
lcd.println(seconds);
In other words ... did you notice that there is no description for an lcd.println() function ?

Don
Logged

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

I see what your saying, so do I need to change what function I am using or define <CR> and <LF> so that they do not appear on the screen. I am new to Arduino so could someone give an example code for what I need to do please?

Kind Regards
Logged

rome
Offline Offline
Sr. Member
****
Karma: 17
Posts: 483
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

use lcd.print instead of lcd.println. That's all.
Logged

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

Quote
I see what your saying, so do I need to change what function I am using ...
Yes. As GUNN has explained already.

Quote
... or define <CR> and <LF> so that they do not appear on the screen.
There's no way to do that.  The definitions are engraved in the computer equivalent of stone, in Read only Memory.

You have to understand that these character LCDs are not designed to replace CRT displays.  They are designed to display short messages on printers, toasters, etc.  To put stuff on a new line you have to use the 'set cursor' function.


Don
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7197
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You have to control display cursor yourself if you want a new line with lcd.setCursor(x,y)
If you are already on the bottom line and do another new line, write the bottom line on the top line, and new line on the bottom line to make the message scroll.
You need to have a buffer as large as the size of the display and use it to do the new lines and scroll.

You need more effort to do what you want: scrolling and new line. On the other hand, I sell a serial LCD that will do this for you plus a bunch of other stuff. Here is the link.
Logged


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

Thankyou guys!

I guess I totally misunderstood the LCD.Println() function completely!  smiley-kiss

Liudr, did you get my message about using the rotary shaft encoder (phi_interface) to control variables ( i cant seem to do it) and to change the pin designation for channel A and B (changing the numbers in the define part of the code doesnt seem to work)

Kind Regards
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7197
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thankyou guys!

I guess I totally misunderstood the LCD.Println() function completely!  smiley-kiss

Liudr, did you get my message about using the rotary shaft encoder (phi_interface) to control variables ( i cant seem to do it) and to change the pin designation for channel A and B (changing the numbers in the define part of the code doesnt seem to work)

Kind Regards

Yes, I did. Must have read it and somehow forgot  to reply smiley-roll-sweat

You can use this rotary encoder for the purpose. Why not starting a new thread so it's easy to post and read code. Just PM me the thread.
Logged


Pages: [1]   Go Up
Jump to: