Hardware Reference
In-Depth Information
window.onload = function() {
$.get( "command.php", {
key: key, command: "definePinMode&pin=7&mode=1"} );
}
Also, we have to change the command parameters and mention the key for the function
that is called when a button is clicked:
if (clicked_id == "1"){
$.get( "command.php", {
key: key, command: "setDigitalOutput&pin=7&output=1"} );
}
Inside the PHP file, we now have to get two parameters, the command and API key from
Teleduino:
$key = $_GET['key'];
$command = $_GET['command'];
We also need to modify the service URL, as shown in the following code:
$service_url = 'http://us01.proxy.teleduino.org/api/1.0/
328.php?k=' .
$key . '&r=' . $command;
$curl = curl_init($service_url);
The rest of the files are strictly identical, as seen in the previous section.
Note
The code for this section can be found in the GitHub repository for this chapter at ht-
tps://github.com/openhomeautomation/arduino-networking/tree/master/chapter4 .
You can now put all the files for this modified interface inside a folder at the root of your
web server. Also, make sure that the web server is still running. You can open the HTML
file and you should see exactly the same interface as before.
You can now try to click on a button and you should instantly hear the relay switch. The
advantage over the previous section of the chapter is that this interface can now work
Search WWH ::




Custom Search