Hardware Reference
In-Depth Information
EthernetClient Client;
Now, in the setup() function of the sketch, we initialize the Ethernet shield using the
begin() function. If this function is successful (meaning that the Ethernet shield got an
IP address), we reset the Teleduino object:
if ( ! Ethernet.begin(mac))
{
Teleduino328.setStatusLed( 2 , false , 10000 );
Teleduino328.reset();
}
In the 'loop()'' function of the sketch, the important part is to call the Teleduino instance
whenever we are connected to the web:
if (Client.connected())
The rest of the code is about handling the request by the Teleduino service, and we will not
get into the details of this part.
Note that all the files are available on the GitHub repository of the topic:
https://github.com/openhomeautomation/iot-book
It's now time to test the project. Make sure that you grabbed the code from the GitHub
repository, and that you insert the MAC address of your shield and the API key inside the
code. Now, you can upload the code to the Arduino board.
Wait for a moment, and then open your favorite web browser. The first thing we have to
do is to set the pin number 7 as an output. This can be done by typing the appropriate com-
mand in your web browser (make sure to replace yourKey by your own API key):
http://us01.proxy.teleduino.org/api/1.0/328.php?k=yourKey&
r=definePinMode&pin=7&mode=1
Search WWH ::




Custom Search