Joystick controlled Slideshow — Salesforce

This idea is to present something cool for the Salesforce users / subscribers / developers who want to have the basic understanding of how IOT works.

Internet Of Things (IOT) gives an ability to touch any hardware devices and further we can communicate our ideas using cloud (far more possible using CRMs like Salesforce.complatform with the real time connect abilities).

As you can see under these slides (prepared on Reveal JS — A Javascript Framework):

These slides are hosted from Server as well as Client, the only difference is Server isStreaming API Publisher while the Client (an Heroku application in my case is Streaming API Subscriber, which can be hosted in any form either it be localhost or on a platform like Heroku.

Instead of controlling these slides from keyboard or mobile touch, we are giving an extension of moving them using Joystick connected to Arduino UNO — A 37-in-one sensor kit. Using JOHNNY FIVE — A Javascript Framework on top of Firmata protocol, we are able to connect our Node JS server to listen any movements real time.

Here, the Joystick is connected on A0 and A1 pins and the listening of frequent movements is set to 500 milliseconds.

Server Side:

Following is the code snippet from joystick-slideshow.js code:

board.on(“ready”, function () {
console.log(“arduino ready”);
var joystick = new five.Joystick({
pins: [“A0”, “A1”],
freq: 500
var prev = {};
joystick.on(“axismove”, function (err, timestamp) {
if (+this.fixed.x === 1) move(“right”);
if (+this.fixed.x === 0) move(“left”);
if (+this.fixed.y === 1) move(“up”);
if (+this.fixed.y === 0) move(“down”);
if (prev.x !== this.fixed.x || prev.y !== this.fixed.y) {
prev.x = this.fixed.x;
prev.y = this.fixed.y;

Based on the movements so collected using the “axismove” function, we are then transmitting the movement so captured using the Socket IO, so as to make the slides in the direction Joystick was moved.

function move(direction) {
conn.sobject(“Account”).upsert({ // Upsert Table
Name : ‘Record ‘+direction,
accountMaster__c : direction
}, ‘accountMaster__c’, function(err, ret) {
if (!err && ret.success) {
console.log(‘Upsert Successfull’);

We can see that move function is doing 2 tasks:

  1. Making the direction posted to Salesforce,
  2. Making the direction posted to Socket IO to further move the slides on Server side.

Following is the main.js file listening to the Socket IO movements retrieved from Joystick movements as a textual information (left, right, up or down):

var socket = io();
socket.on(“left”, Reveal.left);
socket.on(“right”, Reveal.right);
socket.on(“up”, Reveal.up);
socket.on(“down”, Reveal.down);

So, whenever the Joystick (connected closely to Server application) is moved (Right, Left, Up, Down), we are sending the information to Salesforce to take care of informing the movement just happened to all the subscribers (Desktop or Mobile users).

For this to happen, a real time synchronization APIs are required (like we have Salesforce Streaming API). Here, we are posting the events being made from the Server to the Salesforce standard Account object.

Using the OAuth, we are logging-in to Salesforce via connected apps defined as:

So, this Client ID, Client Secret, Username and Password needs to be placed in config.jsfile. If you are using Sandbox environment, you may need to replace production with Sandbox.

These records are posting using the Streaming Event defined on Account object as:

Client Side:

Following code snippet is from app.js file:

if(config.DEBUG) console.log(‘Subscribing to ‘+ config.PUSH_TOPIC);
var upstreamSub = client.subscribe(config.PUSH_TOPIC, function(message) {
// new inserted/updated record receeived — do something with it
socket.emit(‘record-processed’, JSON.stringify(message));

The above code is subscribing to the Streaming channel named /topic/AllAccountsdefined in config.js file.

This way you can configure your own servers and clients with your Arduino and Joystick to perform this IOT integration with Salesforce.

Watch out this small video demonstrating the Joystick connected with Server. And the listening Clients (iPhone and Desktop).

Using Salesforce Streaming API over Account Object, we are sending the Joystick movements. The server is running on Localhost while client on Heroku instance. Source code for proof of concept at Github link for Server: and Github link for Client:

We can suggest this idea to demonstrate or present any stuffs via Salesforce.

Feel free to contribute here:

Server code: Server Source Code

Client code: Client Source Code