Reputation: 1747
Im looking for a tutorial for controlling the arduino from a web frontend. I already have a cylon/arduino program running.
Do I need api-http? I can't find any documentation on what i'm trying to do. What I want to do is lets say toggle a LED with an HTML button. I tried using the browserify tool but I got some errors. I'm not even sure If for what I want to do I need browserify. (Will post all the info if needed)
Thanks!
Note: I have experience with the MEAN stack.
Upvotes: 2
Views: 326
Reputation: 1747
Im answering my question because I feel that Mike Zhang's answer didn't provide enough info.
So if you have a cylon program copy and paste that to the bottom of your node app.js
For what I wanted to do I just used the express generator and added a link to the ejs that would toggle a variable in my routes/index
which I would require in my app.js
and then added an if statement to my robot code to only run if the variable is true.
Upvotes: 1
Reputation: 104
what you need is cylon-api-socketio.. You can create an html page with your button and whatever controls you want..In your robot code (cylonjs script) create custom "Commands". Enable the socket io server in the script.. Then Those commands can then be invoked on button action in your html page through the socket io api.. cylon-api-socketio actually exposes a large number of commands for each of its drivers. You may not even have to create custom commands. So it would be trivial to invoke the appropiate command.
How To Connect with the SocketIO API
Upvotes: 0
Reputation: 333
From web front send ajax request to backend. At backend serve when it get the ajax request try to call cylon api to control your robot.
Upvotes: 1