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 #194 background imageLoading...
Page #194 background image
onds to give the service some preparation time, and then we read and print
its output character by character.
The clients interface is similar to that of the
Serial
class. The
available
function
checks whether some bytes are still available, and
read
returns the next byte.
At the end, we call
stop
to disconnect from the service, and then we start again.
Note that our program isnt completely robust. If the server needs longer than
300 milliseconds to deliver its data, our program will not read it. In our case
its not a big deal, but for more critical applications, youd better wait until
data is available and add a timeout mechanism.
Compile and upload the program to the Arduino. Then open the serial monitor,
and you should see something like this:
Connecting...connected.
56807 14-11-04 16:34:18 50 0 0 259.2 UTC(NIST) *
Disconnecting.
Connecting...connected.
56807 14-11-04 16:34:20 50 0 0 515.5 UTC(NIST) *
Disconnecting.
Were finished! Our Arduino is directly connected to the Internet, and it even
does something useful: weve turned it into a very accurate clock.
All in all, networking with an Arduino doesnt differ much from networking
with a PC, if you use the Ethernet shield. In the next section, youll learn how
to use services such as DHCP and DNS with an Arduino.
Using DHCP and DNS
In the preceding section, you learned how to access IP services the hard
way. That is, you had to know your own IP address and the servicess IP
address, too. For your home projects, this is convenient and efficient.
As soon as you create projects that have to run in unknown environments,
you have to use a more flexible approach. If youre going to build an actual
product based on a networking Arduino, you certainly dont want your cus-
tomers to enter an unused IP address and upload a new sketch before they
can use it.
In such cases you need a more flexible solution. In this section youll determine
service addresses using the Domain Name System (DNS), and youll obtain
the Arduinos IP address using the Dynamic Host Configuration Protocol
(DHCP).
Heres a version of our time server example that uses DHCP and DNS:
report erratum discuss
Using DHCP and DNS 177
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