Using an Arduino to control applications

Simple arduino controller

Why?

The goal is to create custom objects that can act as controllers for applications built with the framework.

For instance, the videolist example has code for a simple "remote" pictured on the right.

This object features two buttons:

We'll show how to bind both to control the videolist example application.

The design

An arduino with an Ethernet shield can't easily send packets directly to a browser application. There are simple websockets code for arduino but they won't support legacy browsers like socket.io does.

For this reason we have to create a proxy that will basically act as an event forwarder.

This server-side application (using the Node.js adapter could also perform any other action based on what events it receives but in this example it will just act as forwarder.

Arduino design

The code

Here are the files used in this example:

After going through all these components (in a few milliseconds usually), a push on the physical red button triggers a "input",["random"] event on the browser app that can be subscribed to in order to perform the required action.

Your turn!

Happy hacking! Feel free to share your projects with the community to inspire other people ;-)