Hardware Reference
In-Depth Information
Serving a Web Page
Just as the Galileo can contact a web server to get or post information, it can
also act as a simple web server itself. You can use your web browser to con-
nect to it and get information about its input pins (such as sensors you've
connected) or have it actuate an output when a browser connects. To test
out these capabilities, you're going to have a web page update when a button
is pressed.
1. Just as you did in
Figure 4-2
, wire up a button to pin 2 of the Galileo.
2. Connect the Galileo to your network via Ethernet.
3. Create a new sketch with the code from
Example 6-10
and upload it to
your board. This example is based on the Arduino example found in File
→
Examples
→
Ethernet
→
WebServer.
4. Open the serial monitor to see the IP address that was assigned to your
Galileo by your router.
5. Open a web browser, enter that IP into the address bar, and hit Enter.
You should see the following text on screen: “The button is not pressed!” Try
pushing the button and hitting refresh on your browser. You should then see
“The button is pressed!” (
Figure 6-7
)