User manual

002 lcd.print(millis() / 1000)
Since the function
millis()
is very interesting, we will try
another experiment before dealing with the LC-display in more
detail, since the function
millis()
can also be used to measure
time of program runs, as shown in the following example .
Example code: TIME_DIFF
001 // Integrating LCD-Library
002 #include <LiquidCrystal.h>
003
004 // Specifying LCD pins
005 // RS, E, D4, D5, D6, D7
006 LiquidCrystal lcd(11, 10, 2, 3, 4, 5);
007
008 long time_diff, diff;
009
010 void setup()
011 {
012 // LED-Backlighting
013 analogWrite(9, 150);
014
015 // LCD output
016 lcd.begin(16, 2);
017 lcd.setCursor(0, 0);
018 lcd.print("**ARDUINO LCD**”);
019 lcd.setCursor(0, 1);
020 lcd.print("TIME DIFF: ");
021 }
022
023 void loop()
024 {
025 diff = millis();
026
027 // Myprogram start
028
029 lcd.setCursor(11, 1);
030 lcd.print(diff time_diff);
031 delay(100);
032
033 // My program end
034 time_diff = diff;
035 }
The example code shows how to determine the program runtime .
For this, we read the current counter status of
millis()
at every