Hardware Reference
In-Depth Information
Let's now see this PHP file, which is called every time we press a button. We saw that a
variable named command is passed whenever a button is pressed. Inside the PHP file, we
need to get the value of this variable:
$command = $_GET['command'];
Now that we have the command we want to send, we can build the string that will contain
the URL we have to call. That's exactly the same thing we did in the browser when testing
the sketch. Note that again, if the mDNS service is not working for you, you will have to
enter the IP address of your CC3000 board here. This is how we build the variable con-
taining the URL and command to call:
$service_url = 'http://arduino.local'. $command;
Now, we can initialize the cURL service that we already used in the first section of the
topic. This is done with the following piece of code:
$curl = curl_init($service_url);
After that, we execute the command using the following statement:
$curl_response = curl_exec($curl);
Then, close the cURL call with the following code:
$curl_close($curl);
Note that here, we are not really interested with the answer from the Arduino board, so we
won't be using it outside of the PHP file.
Search WWH ::




Custom Search