LCD counts in foreign langauge, how to change ?

So basically i'm making this with my arduino and lcd display ( basic set i bought a few years back)

I can get hello world on the display, and it seems to count everysecond.

the problem is that the counting seems to be done in chinese or korean characters.

I think I'm missing an option somewhere to change this, but i can't seem to find it. And an evening of googling hasn't provided any answers either.

code posted for completeness below.

#include <LiquidCrystal.h>


const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
 
  lcd.begin(16, 2);
 
  lcd.print("hello, world!");
}

void loop() {
  
  lcd.setCursor(0, 1);
  
  lcd.print(millis() / 1000,DEC);
}

Added DEC to the vanilla code posted in the link above, doesn't solve the problem.

I'm surprise you can see anything.
Just to test, add a delay(1000) statement in your loop() to see if the same phenomenon strikes.

Add a delay(500); to the loop and see what happens.

6v6gt:
I'm surprise you can see anything.
Just to test, add a delay(1000) statement in your loop() to see if the same phenomenon strikes.

tried that, doesn't work. Since I think both you and paul__b misunderstand the problem i've attached the pic below .

It is the HelloWorld example from the library, from which the comments werre removed. So it should not be a program problem, rather a connexion problem: check it.
Can you post a picture of the other side of the display? Where did you buy it? Do you have a datasheet?

lesept:
It is the HelloWorld example from the library, from which the comments werre removed. So it should not be a program problem, rather a connexion problem: check it.
Can you post a picture of the other side of the display? Where did you buy it? Do you have a datasheet?

it's an LCM1602C according to the other side. bought it online in 2016
this seems to be the datasheet https://www.waveshare.com/datasheet/LCD_en_PDF/LCD1602.pdf
if i'm reading it correctly based of the font table( page 14), instead of 0011 ( which are the characters I want to use) it's using 1100, things is, i have no idea how to manipulate this specific input.

Not only are the wrong characters displayed, but also the location in which they are displayed is wrong.

slampie:

  lcd.setCursor(0, 1);

... but if you look at the photo attached to reply #3, you will see that the characters in question start at (8,1), not (0,1).

Why don't you just try using the Hello World example as published instead of adding your own 'enhancements'?

Don

From the datasheet page 14 (font table), it seems you get characters for

  • b0-b3 = 1001 and b4-b7 = 1011
  • b0-b3 = 1011 and b4-b7 = 1011
    But as you display the time from millis(), we don't know what should be on the screen.
    Can you try to display "0123456789" to see what you get ?

floresta:
Why don't you just try using the Hello World example as published instead of adding your own 'enhancements'?

Don

i'm trying to build a wake up light without buying any extra parts, just those that came with the starter pack i bought 2 years ago. i'm basically combining the hello world project with the hourglass project, and trying to figure it out by trial and error.

odometer:
Not only are the wrong characters displayed, but also the location in which they are displayed is wrong.
... but if you look at the photo attached to reply #3, you will see that the characters in question start at (8,1), not (0,1).

damm, you are right, didn't even notice that. ( continued below)

lesept:
From the datasheet page 14 (font table), it seems you get characters for

  • b0-b3 = 1001 and b4-b7 = 1011
  • b0-b3 = 1011 and b4-b7 = 1011
    But as you display the time from millis(), we don't know what should be on the screen.
    Can you try to display "0123456789" to see what you get ?

same "strange" charactars as in the font table. This combined with the remark of odometer above, makes me think I connected some wires wrong, since the whole project is rather chaoticly wired( i'm honestly to adshamed to post a picture of it right now :confused: ).
So i'm going to rewire the whole apparatus, which i should do anyway. See what happens and post the results here. If it doens't help it should at least make it clear for someone else to see what i'm trying to do.

to be continued.

slampie:
and trying to figure it out by trial and error.

Bad idea. It will very likely result in you wasting your time as well as ours.

It would help to know: what are you using to keep track of time?

odometer:
Bad idea. It will very likely result in you wasting your time as well as ours.

It would help to know: what are you using to keep track of time?

yeah.. that turned out to be somewhat true, taught me a lot, but probaly a waste of your time.

So what happened was...;
Rewiring didn't solve the problem, so i started looking at the code. since I used the hourglass project, my "start" was the completed code of that project. Since that project uses a tilt switch to emulate the turning of an hourglass that code was still (partly) included. I don't know exactly how that changed the characters ( can dig up the code if anyone really wants to know, since i saved the fixed version in a new file) but taking it out fixed all the problems.

Since I used millis to track the time (I know how unreliably that is/can be, but the starter kit doens't have a better way)
I wanted to display the time as well, so i had to figure out a way to display this, just finished that part, that and a lack time took me a week to react.

code to do that below

if (millis() >0) 
{
Clocktime= millis(); 
 Tenhours = Clocktime /36000000, DEC;  
 Clocktime = Clocktime - (Tenhours * 36000000) ;
 Hours = Clocktime /3600000, DEC;
 Clocktime = Clocktime - (Hours * 3600000);
 Tenminutes = Clocktime /600000, DEC;
 Clocktime = Clocktime - (Tenminutes * 600000);
 Minutes = Clocktime  /60000, DEC;
 Clocktime = Clocktime - (Minutes * 60000);
  TenSeconds = Clocktime /10000, DEC;
  Clocktime = Clocktime - (TenSeconds * 10000) ;
  Seconds = Clocktime /1000, DEC;

  // above calculation makes it so that minutes won't exceed 60 etc. 
   
  lcd.setCursor(15, 1); 
  
  lcd.print(Seconds);  
     lcd.setCursor (14, 1); 
  lcd.print(TenSeconds);   
   lcd.setCursor(13, 1);
 
  lcd.print(Minutes);
   lcd.setCursor(12, 1);
  
  lcd.print(Tenminutes);
   lcd.setCursor(11, 1);
 
  lcd.print(Hours);
 lcd.setCursor(10, 1);
  
  lcd.print(Tenhours);
  delay (1000); }

I'm testing it this night, want to see if the calculation is correct, and how much time is potentially off

uploaded everything here:

I need to do a few more things though

  • need some kind of program/website to make the schematic so anyone can recreate it -> any suggestions ?

  • need to reset the counter after 24 hours --> is there an easy way to reset the whole program after a certain time ?

will also try to figure out if i can add sound, when the final light is turned on, but that depends on what i can get out of the starter kit.

( mods, the problem i have is solved. but the project isn't done yet, so I don't know if this is the correct subforum for this thread)

Clocktime = Clocktime - (Tenhours * 36000000) ;

better for numbers to big for a 16bit integer:

Clocktime = Clocktime - (Tenhours * 36000000UL) ;

The test should always be true, as millis() is always strictly positive, as soon as the first millisecond passes. So you don't need it.

Here is what I'd suggest:

unsigned long Clocktime;
byte Tenhours, Hours, Tenminutes, Minutes, TenSeconds, Seconds;

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  Clocktime = millis();
  Tenhours = Clocktime / 36000000UL;
  Clocktime = Clocktime - (Tenhours * 36000000UL) ;
  Hours = Clocktime / 3600000UL;
  Clocktime = Clocktime - (Hours * 3600000UL);
  Tenminutes = Clocktime / 600000UL;
  Clocktime = Clocktime - (Tenminutes * 600000UL);
  Minutes = Clocktime  / 60000UL;
  Clocktime = Clocktime - (Minutes * 60000UL);
  TenSeconds = Clocktime / 10000UL;
  Clocktime = Clocktime - (TenSeconds * 10000UL) ;
  Seconds = Clocktime / 1000UL;

  // above calculation makes it so that minutes won't exceed 60 etc.

  lcd.setCursor(15, 1);
  lcd.print(Seconds);
  lcd.setCursor (14, 1);
  lcd.print(TenSeconds);
  lcd.setCursor(13, 1);
  lcd.print(Minutes);
  lcd.setCursor(12, 1);
  lcd.print(Tenminutes);
  lcd.setCursor(11, 1);
  lcd.print(Hours);
  lcd.setCursor(10, 1);
  lcd.print(Tenhours);
  delay (1000);

}

Although I'm not sure that the division of UL numbers can correctly fit in bytes. If the display is not correct, you can change this line :
byte Tenhours, Hours, Tenminutes, Minutes, TenSeconds, Seconds;tounsigned long Tenhours, Hours, Tenminutes, Minutes, TenSeconds, Seconds;

If you see some latency in the change of the seconds, it may be due to cumulative precision errors in the delay and the additional time of the rest of the code. You then can change
delay (1000);to some shorter value such as delay (200);

6v6gt:

Clocktime = Clocktime - (Tenhours * 36000000) ;

better for numbers to big for a 16bit integer:

Clocktime = Clocktime - (Tenhours * 36000000UL) ;

If i understand correctly the UL forces it in a unsigned long right ? ( continued below)

lesept:
The test should always be true, as millis() is always strictly positive, as soon as the first millisecond passes. So you don't need it.

Here is what I'd suggest:

unsigned long Clocktime;

byte Tenhours, Hours, Tenminutes, Minutes, TenSeconds, Seconds;

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  Clocktime = millis();
  Tenhours = Clocktime / 36000000UL;
  Clocktime = Clocktime - (Tenhours * 36000000UL) ;
  Hours = Clocktime / 3600000UL;
  Clocktime = Clocktime - (Hours * 3600000UL);
  Tenminutes = Clocktime / 600000UL;
  Clocktime = Clocktime - (Tenminutes * 600000UL);
  Minutes = Clocktime  / 60000UL;
  Clocktime = Clocktime - (Minutes * 60000UL);
  TenSeconds = Clocktime / 10000UL;
  Clocktime = Clocktime - (TenSeconds * 10000UL) ;
  Seconds = Clocktime / 1000UL;

// above calculation makes it so that minutes won't exceed 60 etc.

lcd.setCursor(15, 1);
  lcd.print(Seconds);
  lcd.setCursor (14, 1);
  lcd.print(TenSeconds);
  lcd.setCursor(13, 1);
  lcd.print(Minutes);
  lcd.setCursor(12, 1);
  lcd.print(Tenminutes);
  lcd.setCursor(11, 1);
  lcd.print(Hours);
  lcd.setCursor(10, 1);
  lcd.print(Tenhours);
  delay (1000);

}



Although I'm not sure that the division of UL numbers can correctly fit in bytes. If the display is not correct, you can change this line :
`byte Tenhours, Hours, Tenminutes, Minutes, TenSeconds, Seconds;`to`unsigned long Tenhours, Hours, Tenminutes, Minutes, TenSeconds, Seconds;`

If you see some latency in the change of the seconds, it may be due to cumulative precision errors in the delay and the additional time of the rest of the code. You then can change 
`delay (1000);`to some shorter value such as `delay (200);`

All the tenminutes, minutes and such are already defined as unsigned longs at the beginning of the program, can be found @ the url i provided, and it works so....

put delay on a second since i found it annoying when the display switches numbers al the time, every second seems to be acceptable.

wouldn't the latency be greater if the calculation was performed multiple times per second as opposed to once every second ?

You are right about the millis>0 thing though. will probably take it out.

still looking for a way to reset every 24 hours.

slampie:
still looking for a way to reset every 24 hours.

Make a test : just after the millis() line, put

if (Clocktime > 24 * 3600 * 1000UL) Clocktime = 0;

lesept:

if (Clocktime > 24 * 3600 * 1000UL) Clocktime = 0;

That UL is too late, 243600 is still intint. Make it

if (Clocktime > 24UL * 3600 * 1000) Clocktime = 0;

slampie:
yeah.. that turned out to be somewhat true, taught me a lot, but probaly a waste of your time.

So what happened was...;
Rewiring didn't solve the problem, so i started looking at the code. since I used the hourglass project, my "start" was the completed code of that project. Since that project uses a tilt switch to emulate the turning of an hourglass that code was still (partly) included. I don't know exactly how that changed the characters ( can dig up the code if anyone really wants to know, since i saved the fixed version in a new file) but taking it out fixed all the problems.

The reason we were not able to help you solve your problem was that we did not have the right information to be able to help you.

From what you wrote in your first post, it sounded as though you were running an exact copy of the sketch from https://www.arduino.cc/en/Tutorial/HelloWorld when this problem occurred. If you had told us that you had made additions to that sketch, and shown us the code you were actually running, then we would likely have been able to find the real problem and help you fix it.

lesept:
Make a test : just after the millis() line, put

if (Clocktime > 24 * 3600 * 1000UL) Clocktime = 0;

oqibidipo:
That UL is too late, 243600 is still intint. Make it

if (Clocktime > 24UL * 3600 * 1000) Clocktime = 0;

You are both wrong.

Take a look again at the code from reply #14, especially this line:

  Clocktime = millis();

The way you two have it, the clock will correctly count up to either 05:47:43 or 23:59:59, at which point it will jump to 00:00:00 and stay frozen at 00:00:00 for about seven weeks (until millis() overflows), at which point it will start counting up again.

lesept:
Here is what I'd suggest:

unsigned long Clocktime;

byte Tenhours, Hours, Tenminutes, Minutes, TenSeconds, Seconds;

I would suggest being more consistent with your capitalization. To you, the difference between Variablename and VariableName might not matter, but to the compiler it very much does matter, and if you use one system for all of your variable names, that will make things easier for yourself and anyone else who wishes to read or modify your code.