Value of an integer to be shown on LCD.

You can get second to the nearest 10th:

long then = millis();
//do something
long now = millis();
long duration = now - then;
duration /= 100; // duration is now in tenths of a second.
float secs = (float)duration / 10.0;

Both lcd libraries determine RW pin (for example 12). If lcd used for writing only, can be pin 12 used as an extra I/O?

Both lcd libraries determine RW pin (for example 12). If lcd used for writing only, can be pin 12 used as an extra I/O?

I presume that you mean the serial read rx by RW. If you just set it to your normal arduino rx pin then it should be fine.

Mowcius

Both lcd libraries determine RW pin (for example 12). If lcd used for writing only, can be pin 12 used as an extra I/O?

By default, the LCD4bit library does not use RW, but note this is defined as pin 11, pin 12 is used for the RS line.

I suggest you may want to try the latest LiquidCrystal library before writing too much code for the less capable LCD4bit library.

Thank You for the answers. I will try to rewrite program for the LiquidCrystal. The reason I did not do it before, is, the LCD-shield was bought in internet, is already soldered and setup instructions are given for LCD4Bit.
Initialisation for LiquidCrystal is not yet clear. Two different options found:

  1. LiquidCrystal(rs, rw, enable, d4, d5, d6, d7);
    2.LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    As can be seen, different number of parameters is used.
    By the way what is the reason for writing 2 different headers for LCD?

The latest LCD4bit library available from the playground uses these pin assignments:

#define RS 7 // LCD pin 4
#define RW 6 // LCD pin 5 (not used if USING_RW = false
#define Enable 5 // LCD pin 6
DB4~7 = Arduino pins 9,10,11,12

Is your LCD wired up to those arduino pins?

The LiquidCrystal code for those pin assignments assuming that pin 6 (RW) is not connected to arduino:
LiquidCrystal(7, 5, 9,10,11,12);

LiquidCrystal can tell if you want to us the RW pin or not through the number of parameters you give it. If in your case you do not want to use RW the then you would be using the form: LiquidCrystal(RS, Enable, DB4, DB5, DB6, DB7)

After the values were inserted:
LiquidCrystal lcd(8, 9, 4,5,6,7);
it run OK.
Thank You for the help.
If value should be increased by 1, we use:
int i++;
How can we increase by 10 or by other value?

You don't use "int i++;". You use:

int i;
// Value i somehow

i++;

To increment by a different value, such as 10:

i += 10;

Thank You PaulS.
Arduino has 2 pins: 0 and 1, which used to download a program.
Can we use them as extra I/O if we don't use serial communication at the run?

The following works fine for me ...

#include <LiquidCrystal.h>

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

void setup() {
lcd.begin(16, 2);
lcd.noCursor();
}

void loop() {
int i;
for (i = 0; i < 256; i++) {
lcd.clear();
lcd.print (i);
lcd.setCursor(0, 1);
lcd.print (char(i));
delay(1500);
}
}

Thank You PaulS.
Arduino has 2 pins: 0 and 1, which used to download a program.
Can we use them as extra I/O if we don't use serial communication at the run?

You could, but it's not suggested. Just for the fact that you'll generally need to use them sooner or later for some sort of debug.

You can always use analoginput pins just the same as digital pins! Just need to address them as 14-19 instead. (analog 0 = 14, analog 5 = 19), so to blink an LED on analogpin 0:
const byte ledPin = 14;
void setup()
{
pinMode(ledPin, OUTPUT);
}

void loop()
}
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}

Thank You Captain.
Let's assume that a value of an integer should be changed. To do it quicker, we move cursor left and right, then increment or decrement with Up and Down buttons. Depending on position of cursor it will automatically changed by 1, 10, 100... How to write a program, which recognize where the cursor is?

Have some ideas how to do it.
int value;//value to be shown on lcd
int value_col; //lcd column where the value will be placed
int cursor_col;//column where the cursor is placed
int value_change; //by this value suppose to be changed 1, 10, 100, ..

value_change= ???
// the expression is:
// value_change=10^((value_col-cursor_col)+(lg value)+1)
//
value+=value_change;
How to write expressions like: in power of, or logarithm ?