The fastest you can control the LED from a web page would be about 1-2 seconds. That means you click the button on your page and the LED might not light until 1 second passes.
There is propagation time between your shared webhost, the cloud, the agent, and the device.
It would be faster if the agent was your webhost (webpage on the agent not your website). But then, you have to use your agent URL, which might be a deal-breaker. You usually don’t want people to know your agent URL.
So your LED control would be a button on your page that then uses PHP to POST an LED ON or LED OFF command. I use PHP CURL because it hides your agent URL from people viewing your webpage HTML source.
on your page (for people to see). The only reason you would want the imp to post values to the website would be for data logging in an online database file.
If you want to test the LED part first …
- Create a form on your website. For the test, you can use your Agent URL.
something like this (but use your real agent key, not my fake one) …
`<form action="https://agent.electricimp.com/b8JwdGn9UY0g" method="post">
<input type="hidden" name="led" value="on">
<input type="submit" name="submit" value="TURN ON LED">
<form action="https://agent.electricimp.com/b8JwdGn9UY0g" method="post">
<input type="hidden" name="led" value="off">
<input type="submit" name="submit" value="TURN OFF LED">
(as always, this forum editor is crap … ignore the semi-colons in the tags)
Your simple form test using POST will not look very elegant on your web page, but it will test your agent and device code to see of they successfully receive your POSTed value.
Program your agent to send the value to your device and do the LED thing.
If you can get that to work, turning on or turning off the LED, let me know.
The PHP portion to hide the URL can be done later.
The final steps would be to use JQuery, AJAX, etc. for the User Interface.