Programming Arduino Getting Started with Sketches



Yüklə 5,42 Kb.
Pdf görüntüsü
səhifə67/78
tarix22.12.2023
ölçüsü5,42 Kb.
#189286
1   ...   63   64   65   66   67   68   69   70   ...   78
Arduino SimonMonk 2011

<
and then the tag name, and then a 
>
; for example, 

. The
end of a tag is similar except that it has a 
/
after the 
<
. In the preceding example, the
outermost tag is 

that contains a tab called 

. All web pages should start
with such tags, and you can see the corresponding ends for those tags at the end of the file.
Note that you have to put the end tags in the right order, so the 
body
tag must be closed
before the 
html
tag.
Now we get to the interesting bit in the middle, the 
h1
and 
p
tags. These are the parts of
the example that are actually displayed.
The 
h1
tag indicates a level 1 header. This has the effect of displaying the text that it
contains in a large bold font. The 
p
tag is a paragraph tag, and so all the text contained
within it is displayed as a paragraph.
This really just scratches the surface of HTML. Many books and Internet resources are
available for learning about HTML.


Figure 10-2
An HTML example
Arduino as a Web Server
The first example sketch simply uses the Arduino and Ethernet shield to make a small web
server. It’s definitely not a Google server farm, but it will allow you to send a web request
to your Arduino and view the results in a browser on your computer.
Before uploading the sketch 10–01, there are a couple of changes that you need to
make. If you look at the top of the sketch, you will see the following lines:
The first of these, the 
mac
address, must be unique among all the devices connected to
your network. The second one is the IP address. Whereas most devices that you connect to
your home network will have IP addresses assigned to them automatically by a protocol
called Dynamic Host Configuration Protocol (DHCP), this is not true for the Ethernet
shield. For this device, you have to define an IP address manually. This address cannot be
any four numbers; they must be numbers that qualify as being internal IP addresses and fit
in the range of IP addresses expected by your home router. Typically, the first three
numbers will be something like 10.0.1.
x
or 192.168.1. 
x
, where 
x
is a number between 0
and 255. Some of these IP addresses will be in use by other devices on your network. To
find an unused but valid IP address, connect to the administration page for your home
router and look for an option that says “DHCP.” You should find a list of devices and their
IP addresses, similar to that shown in 
Figure 10-3
. Select a final number to use in you IP
address. In this case, 192.168.1.30 looked like a good bet, and indeed it worked fine.
Attach the Arduino to your computer using the USB lead and upload the sketch. You
can now disconnect the USB lead and attach the power supply to the Arduino and the
Ethernet lead.


Open a connection on your computer’s browser to the IP address that you assigned for
the Ethernet shield. Something very much like 
Figure 10-4
 should appear.

Yüklə 5,42 Kb.

Dostları ilə paylaş:
1   ...   63   64   65   66   67   68   69   70   ...   78




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin