there is no problem when compiling but nothing shows on display. Could anybody help me with it?
#include <LiquidCrystal.h>
#include <Time.h>
#define TIME_MSG_LEN 11 // time sync to PC is HEADER followed by Unix time_t as ten ASCII digits #define TIME_HEADER 'T' // Header tag for serial time sync message #define TIME_REQUEST 7 // ASCII bell character requests a time sync message
void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
void processSyncMessage() {
// if time sync available from serial port, update time and return true
while(Serial.available() >= TIME_MSG_LEN ){ // time message consists of header & 10 ASCII digits
char c = Serial.read() ;
Serial.print(c);
if( c == TIME_HEADER ) {
time_t pctime = 0;
for(int i=0; i < TIME_MSG_LEN -1; i++){
c = Serial.read();
if( c >= '0' && c <= '9'){
pctime = (10 * pctime) + (c - '0') ; // convert digits to a number
}
}
setTime(pctime); // Sync Arduino clock to the time received on the serial port
}
}
}
void digitalClockDisplay(){
// digital clock display of the time
check the pins you have connected for the LCD are the same as the ones for the Hello World one.
The reason I say that is that you have defined LiquidCrystal lcd(12, 11, 10, 6, 4, 3, 2); <<<< 7 pins
in your sketch but the Hello World one has LiquidCrystal lcd(7, 8, 9, 10, 11, 12); <<<< 6 pins
so you may just have it defined differently to how it is connected.
I would suggest you copy and paste what you have for the Hello World sketch and then re-connect the pins of the arduino to your LCD to correspond.
hth
Norman
check the pins you have connected for the LCD are the same as the ones for the Hello World one.
The reason I say that is that you have defined LiquidCrystal lcd(12, 11, 10, 6, 4, 3, 2); <<<< 7 pins
in your sketch but the Hello World one has LiquidCrystal lcd(7, 8, 9, 10, 11, 12); <<<< 6 pins
so you may just have it defined differently to how it is connected.
There is no reason to always use the same pins for an LCD display and there are provisions for using 6, 7, 10 or 11 connections between the LCD and the Arduino. That is why the comment says: "// put your pin numbers here".
This information is documented but the documentation is hard to find, and there is only one poor example that does not really explain the syntax. Look here: --> LiquidCrystal - Arduino Reference
Are you having problem with your 'screen' which I would interpret as the serial monitor, with your 'display' which I would interpret as the LCD, or both?
I commetted out the serial instructions in your code, set c to a dummy value and changed the lcd declaration as Norman said. If today was January 1, 1970 your code would be perfect.