When the Update button is pressed, a second request is sent to the Arduino. This will be
just like the first request, except that the request will contain request parameters that will
contain the values of the pins.
A request parameter is similar in concept to a function parameter. A function parameter
enables you to get information to a function, such as the number of times to blink, and a
request parameter enables you to pass data to the Arduino that is going to handle the web
request. When the Arduino
receives the web request, it can extract
the pin settings from
the request parameter and change the actual pins.
The code for the second example sketch follows:
The sketch uses two arrays to control the pins. The first,
pins
, just specifies which pins
are to be used. The
pinState
array holds the state of each pin: either 0 or 1.
To get the information coming from the browser form about which pins should be on
and which should be off, it is necessary to read the header coming from the browser. In
fact, all you need is contained in the first line of the header. You will use a character array
line1
to contain the first line of the header.
When the user clicks on the Update button and submits the form from the browser, the
URL for the page will look something like this:
The request parameters come after the
Dostları ilə paylaş: