void setup() {
Wire.begin();
if (Ethernet.begin(mac) == 0) {
Serial.println(“Failed to configure Ethernet using DHCP”);
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
Udp.begin(localPort);
}
void loop() {
char tt[128];
sendNTPpacket(timeServer);
delay(1000);
if ( Udp.parsePacket() ) {
Udp.read(packetBuffer,NTP_PACKET_SIZE); // read the packet into the buffer
unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
// combine the four bytes (two words) into a long integer
// this is NTP time (seconds since Jan 1 1900):
unsigned long secsSince1900 = highWord << 16 | lowWord;
const unsigned long seventyYears = 2208988800UL;
unsigned long epoch = secsSince1900 - seventyYears;
int hh = ((epoch % 86400L) / 3600) + 9;
switch(hh) {
case 24: hh = 0; break;
case 25: hh = 1; break;
case 26: hh = 2; break;
case 27: hh = 3; break;
case 28: hh = 4; break;
case 29: hh = 5; break;
case 30: hh = 6; break;
case 31: hh = 7; break;
case 32: hh = 8; break;
}
int mm = (epoch % 3600) / 60;
int ss = epoch % 60;
sprintf(tt,"i'mano/ji'kokuwa ji fun byo’-de_su. \r”,hh,mm,ss);
AquesTalkPico_Send(tt);
}
delay(15000);
}