EasyManuals Logo

Arduino uno User Manual

Arduino uno
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 #196 background imageLoading...
Page #196 background image
delay(300);
-
-
while (client.available()) {
-
char c = client.read();
-
Serial.print(c);
35
}
-
-
Serial.println("Disconnecting.");
-
client.stop();
-
}
40
}
-
-
void print_ip_address(IPAddress ip) {
-
const unsigned int OCTETS = 4;
-
Serial.print("We've got the following IP address: ");
45
for (unsigned int i = 0; i < OCTETS; i++) {
-
Serial.print(ip[i]);
-
if (i != OCTETS - 1)
-
Serial.print(".");
-
}
50
Serial.println();
-
}
-
This program does the same as the program in the previous section, but it
doesnt contain any explicit IP addresses. Apart from that, it doesnt differ
much from the original version. The first difference is in line 8. Here we no
longer declare the variable
time_server
as an
IPAddress
object but as a string. The
string contains the name of the server were going to connect to.
In line 13, we no longer pass our own IP address to
Ethernet
s
begin
method. In
this case,
begin
tries to obtain an unique IP address using a DHCP server in
the local network. If it cannot obtain an IP address, we start an endless loop
that prints an error message every second. Otherwise, we print the IP address
weve got, using a small helper function named
print_ip_address
.
Eventually, in line 27, we pass our
time_server
string to the
connect
method. Note
that we didnt change the line; weve only changed the type of the
time_server
variable. If
connect
gets a string and not an
IPAddress
object, it tries to look up
the IP address belonging to the server name stored in the string using DNS.
Run the program, and youll see output similar to the following:
We've got the following IP address: 192.168.2.113
Connecting...connected.
56807 14-11-04 16:34:18 50 0 0 259.2 UTC(NIST) *
Disconnecting.
report erratum discuss
Using DHCP and DNS 179
www.it-ebooks.info

Table of Contents

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

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

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals