I want to use a Particle Core or Photon to run a robot. I found projects that use ESP 8266 to run robots over a WiFi, so I though it would be nice to use the Particles I have around. First I controlled the robot using the Cloud (Particle Build and Console), but there is too much lag to be very useful for driving a robot.
My next approach is to have have the Particle serve up a simple web page with buttons for control on my local WiFi. This has been frustrating.
I modified and flashed TINYWEBSERVER.INO successfully
What I cannot figure out is how the Particle can respond to button pushes on the web page. I’d like to start with a “Push to Toggle LED” button.
I’ve looked through the documentation and found these:
-
Webpages on Photon / SoftAP Web pages on Photon/SoftAP. This documentation has a page callback function in the documentation with “an example”. The discussion is focused on how to connect to a Particle to a Wifi. I need something simpler.
-
https://docs.particle.io/reference/firmware/photon/#softap-http-pages - SoftAP Pages
This it too complicated. The “Complete Example” is virtually impossible to understand. And, BTW, it is not complete because it has no setup and loop functions.
I can follow (with difficulty) the HTML page that is stored as one long string. I cut and pasted it into an editor and manually broke it into lines.
As Far As I Can Tell (AFAICT) several JavaScript libraries are defined as almost incomprehensible strings. A couple to handle RSA encryption, I think. Then finally a string variable script_js that defines the functions to handle the call backs.
I guess it works, but it is not very helpful for my much simpler task.
What do I need to just push a button on a served web page, and turn an LED on and off?