EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #191 background imageLoading...
Page #191 background image
we use the service programmatically with an Arduino, see how it works using
the
telnet
command:
maik> telnet time.nist.gov 13
Trying 192.43.244.18...
Connected to time.nist.gov.
Escape character is '^]'.
56965 14-11-04 20:33:03 00 0 0 867.4 UTC(NIST) *
Connection closed by foreign host.
As soon as the
telnet
command connects to the Daytime server, it sends back
the current time and date.
10
Then the service shuts down the connection
immediately.
Heres an implementation of exactly the same behavior for an Arduino with
an Ethernet shield:
Ethernet/TimeServer/TimeServer.ino
#include <SPI.h>
Line 1
#include <Ethernet.h>
-
const unsigned int BAUD_RATE = 9600;
-
const unsigned int DAYTIME_PORT = 13;
-
5
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-
IPAddress my_ip(192, 168, 2, 120);
-
IPAddress time_server(192, 43, 244, 18); // time.nist.gov
-
EthernetClient client;
-
10
void setup() {
-
Serial.begin(BAUD_RATE);
-
Ethernet.begin(mac, my_ip);
-
}
-
15
void loop() {
-
delay(1000);
-
Serial.print("Connecting...");
-
-
if (client.connect(time_server, DAYTIME_PORT) <= 0) {
20
Serial.println("connection failed.");
-
} else {
-
Serial.println("connected.");
-
delay(300);
-
while (client.available()) {
25
char c = client.read();
-
Serial.print(c);
-
}
-
-
10. See
http://www.nist.gov/physlab/div847/grp40/its.cfm
for a detailed description of the date strings
format.
Chapter 10. Networking with Arduino 174
report erratum discuss
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino Pro Mini and is the answer not in the manual?

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals