Programming Arduino Getting Started with Sketches


? and are each separated by an  &



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

?
and are each separated by an 
&
. Looking at the
first parameter (
0=1
), this means that the first pin in the array (
pins[0]
) should have the
value 1. If you were to look at the first line of the header, you would see those same
request parameters there:
Before the parameters, there is the text 
GET/.
This specifies the page requested by the
browser. In this case, 
/
indicates the root page.
In the loop of the sketch, you call the 
readHeader
function to read the first line of the
header. You then use the 
pageNameIs
function to check that the page request is for the
root page 
/
.
The sketch then generates the header and the start of the HTML form that is to be
displayed. Before writing the HTML for each of the pins, the sketch calls the
setValuesFromParams
function to read each of the request parameters and set the
appropriate values in the 
pinStates
array. This array is then used to set the values of the
pin outputs before the 
writeHTMLforPin
function is called for each of the pins. This
function generates a selection list for each pin. It has to build this list part by part. The 
if
statements ensure that the appropriate options are selected.
The functions 
readHeader, pageNameIs
, and 
valueOfParam
are useful general-
purpose functions that you can make use of in your own sketches.
You can use your multimeter as you did in 
Chapter 6
to verify that the pins are indeed


turning on and off. If you are feeling more adventurous, you could attach LEDs or relays
to the pins to control things.
Conclusion
Having used shields and associated libraries in the last two chapters, it is now time to
investigate the features that enable libraries to be written and learn how to write libraries
of your own.




Yüklə 5,42 Kb.

Dostları ilə paylaş:
1   ...   66   67   68   69   70   71   72   73   ...   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