Controlling robots
 using JavaScript




 Sudar Muthu (@sudarmuthu)
 Research Engineer, Yahoo! Labs
 http://hardwarefun.com
 http://github.com/sudar
Who am I?
 Research Engineer by profession
 Creates robots as hobby
 Prefers Arduino
 Prefers JavaScript at work
 Why not combine both of them?
 .. and that’s what I am going to talk about today
Why hardware for a software hacker?




           Fun!
Let’s start with a demo




       Demo
  http://hardwarefun.com/projects/asimijs
Participate in the demo 




          Visit
    http://hardwarefun.com:3000
Control the bot at stage
               http://hardwarefun.com/projects/asimijs




#asimijs @hardwarefun
Arduino
 Visual Basic for hardware
 Includes both Hardware and software




                         Photo credit Arduino team
Interfacing Arduino with JavaScript

 Using serial connection (node-serialport)
 Using abstraction (like johnny-five or duino)
 Using serial Bluetooth connection (asimijs)
Using Serial Connection
You need node-serialport - https://github.com/voodootikigod/node-serialport

var SerialPort = require("serialport").SerialPort,
  arduino = new SerialPort("/dev/tty/ACM1");

// when data is received from arduino
arduino.on("data", function (data) {
    arduino.write(new Buffer[data]);
    console.log("Got: " + data);
});

// if there was any error
arduino.on("error", function (data) {
    console.log("Error: " + data);
});
Using Abstraction

 Build on top of node-serialport -
  https://github.com/voodootikigod/node-serialport
 Options include Johnny-five -
  https://github.com/rwldrn/johnny-five and duino -
  https://github.com/ecto/duino
 Load the firmdata program into Arduino
 It provides the necessary abstraction
 Write code using a node.js library
 Profit 
Demo




Let there be LIGHT
Code
var five = require("johnny-five"),
  board = new five.Board();

board.on("ready", function() {

 // Create an Led on pin 13
 (new five.Led(13)).strobe(1000);

});
Hardware setup
Reading sensor data

   What you need?



Any sensor and a LED
Reading sensor data
var five = require("johnny-five"),
  board, led, photoresistor;

board = new five.Board();
board.on("ready", function() {

 // Create a new `photoresistor` hardware instance.
 photoresistor = new five.Sensor({pin: "A2”, freq: 250});
 led = new five.Led(13);

  // "read" get the current reading from the photoresistor
  photoresistor.on("read", function( err, value ) {
      if (value > 50) {
          led.on();
      } else {
          led.off();
      }
    console.log( value, this.normalized );
  });
  // Inject the `sensor` hardware into the Repl instance's context;
  // allows direct command line access
  board.repl.inject({
    pot: photoresistor
  });
});
Using serial Bluetooth connection

 Bluetooth shield gives wireless capability to Arduino
 A Bluetooth connection appears as serial port in your
  computer
 Using node-serialport you can talk wirelessly to Arduino
 And that’s what I did for demo ;)
Using serial Bluetooth connection
var SerialPort = require("serialport").SerialPort,
  bt = new SerialPort("/dev/cu.FireFly-CCFA-SPP");

// when data is received from bluetooth
bt.on("data", function (data) {
    bt.write(new Buffer[data]);
    console.log("Got: " + data);
});

// error reading bluetooth serial port
bt.on("error", function (data) {
    console.log("Error: " + data);
});
How the demo worked

                Node.js Server




                                 Node Client



Admin page


                  User page
                   User page
                     User page
Links
 AsimiJS – The demo that I showed initially
  http://hardwarefun.com/projects/asimijs
 Asimi – A simple bot using Arduino
  http://hardwarefun.com/project/asimi
 Getting started with hardware programming
  http://hardwarefun.com/tutorials/getting-started-with-
  hardware-programming
 Getting started with Arduino
  http://hardwarefun.com/tutorials/getting-started-with-arduino-
  and-avr
 Node-serialport https://github.com/voodootikigod/node-
  serialport
 Johnny Five https://github.com/rwldrn/johnny-five
Questions

Thank You

Sudar Muthu (@sudarmuthu)
  http://hardwarefun.com
  http://gitbub.com/sudar

More Related Content

KEY
Android and Arduio mixed with Breakout js
PPTX
Home sensor prototype on Arduino & Raspberry Pi with Node.JS
PPTX
Js robotics
PDF
[H3 2012] 우리가 모르는 Node.js로 할 수 있는 몇가지
PDF
Build Lifecycle Craftsmanship for the Transylvania JUG
PDF
Metasepi team meeting #6: "Snatch-driven development"
PDF
Detecting headless browsers
Android and Arduio mixed with Breakout js
Home sensor prototype on Arduino & Raspberry Pi with Node.JS
Js robotics
[H3 2012] 우리가 모르는 Node.js로 할 수 있는 몇가지
Build Lifecycle Craftsmanship for the Transylvania JUG
Metasepi team meeting #6: "Snatch-driven development"
Detecting headless browsers

What's hot (12)

PDF
JavaScript in the Real World
TXT
PDF
My Robot Poops - In JavaScript (with web sockets)
PDF
Why use JavaScript in Hardware? GoTo Conf - Berlin
PDF
Couverture de code
PDF
Mojolicious lite
PDF
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...
PDF
Continuous Integration for iOS (iOS User Group Berlin)
PDF
Continuous Integration for iOS
PDF
Bundler is the Best
PDF
CasperJS and PhantomJS for Automated Testing
PDF
Let's begin io t with $10
JavaScript in the Real World
My Robot Poops - In JavaScript (with web sockets)
Why use JavaScript in Hardware? GoTo Conf - Berlin
Couverture de code
Mojolicious lite
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...
Continuous Integration for iOS (iOS User Group Berlin)
Continuous Integration for iOS
Bundler is the Best
CasperJS and PhantomJS for Automated Testing
Let's begin io t with $10
Ad

Similar to Controlling robots using javascript (20)

PPTX
Using arduino and raspberry pi for internet of things
PPTX
BURO Arduino Workshop
PPTX
Lab Handson: Power your Creations with Intel Edison!
ODP
Javascript robotics
PPTX
IoT on Raspberry Pi
PPTX
Setting Apple's UI Automation Free with Appium
PDF
Programming objects with android
PDF
Hardware Hacking
PPTX
Arduino based IoT Application Programming_20180814.pptx
PPTX
Lets make robots
PPTX
Exploring the Internet of Things Using Ruby
PPTX
pcDuino Presentation at SparkFun
PDF
Porting your favourite cmdline tool to Android
PPTX
PPTX
IoT with openHAB on pcDuino3B
PPTX
Setting UIAutomation free with Appium
PDF
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
PPTX
Building your own RC Car with Raspberry Pi
PPTX
Fund. of IoT LAB - CO 252.pptx
PDF
Arduino Development For Beginners
Using arduino and raspberry pi for internet of things
BURO Arduino Workshop
Lab Handson: Power your Creations with Intel Edison!
Javascript robotics
IoT on Raspberry Pi
Setting Apple's UI Automation Free with Appium
Programming objects with android
Hardware Hacking
Arduino based IoT Application Programming_20180814.pptx
Lets make robots
Exploring the Internet of Things Using Ruby
pcDuino Presentation at SparkFun
Porting your favourite cmdline tool to Android
IoT with openHAB on pcDuino3B
Setting UIAutomation free with Appium
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
Building your own RC Car with Raspberry Pi
Fund. of IoT LAB - CO 252.pptx
Arduino Development For Beginners
Ad

More from Sudar Muthu (20)

PPTX
A quick preview of WP CLI - Chennai WordPress Meetup
PDF
WordPress Developer tools
PDF
WordPress Developer Tools to increase productivity
PDF
Unit testing for WordPress
PDF
Unit testing in php
PPTX
How arduino helped me in life
PPTX
Having fun with hardware
PPTX
Getting started with arduino workshop
PPTX
Python in raspberry pi
PPTX
Hack 101 at IIT Kanpur
PPTX
PureCSS open hack 2013
PPTX
Pig workshop
PPTX
Arduino Robotics workshop day2
PPTX
Arduino Robotics workshop Day1
PPTX
Hands on Hadoop and pig
PPTX
Capabilities of Arduino (including Due)
PPTX
Picture perfect hacks with flickr API
PPTX
Hacking 101
PPTX
Capabilities of Arduino
PPTX
Introduction to node.js GDD
A quick preview of WP CLI - Chennai WordPress Meetup
WordPress Developer tools
WordPress Developer Tools to increase productivity
Unit testing for WordPress
Unit testing in php
How arduino helped me in life
Having fun with hardware
Getting started with arduino workshop
Python in raspberry pi
Hack 101 at IIT Kanpur
PureCSS open hack 2013
Pig workshop
Arduino Robotics workshop day2
Arduino Robotics workshop Day1
Hands on Hadoop and pig
Capabilities of Arduino (including Due)
Picture perfect hacks with flickr API
Hacking 101
Capabilities of Arduino
Introduction to node.js GDD

Recently uploaded (20)

PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Five Habits of High-Impact Board Members
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Architecture types and enterprise applications.pdf
PPTX
Modernising the Digital Integration Hub
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PPT
Geologic Time for studying geology for geologist
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Zenith AI: Advanced Artificial Intelligence
DOCX
search engine optimization ppt fir known well about this
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
A proposed approach for plagiarism detection in Myanmar Unicode text
sustainability-14-14877-v2.pddhzftheheeeee
The influence of sentiment analysis in enhancing early warning system model f...
Getting started with AI Agents and Multi-Agent Systems
Taming the Chaos: How to Turn Unstructured Data into Decisions
Five Habits of High-Impact Board Members
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
1 - Historical Antecedents, Social Consideration.pdf
Architecture types and enterprise applications.pdf
Modernising the Digital Integration Hub
sbt 2.0: go big (Scala Days 2025 edition)
Improvisation in detection of pomegranate leaf disease using transfer learni...
Geologic Time for studying geology for geologist
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
NewMind AI Weekly Chronicles – August ’25 Week III
Custom Battery Pack Design Considerations for Performance and Safety
Zenith AI: Advanced Artificial Intelligence
search engine optimization ppt fir known well about this
Final SEM Unit 1 for mit wpu at pune .pptx

Controlling robots using javascript

  • 1. Controlling robots using JavaScript Sudar Muthu (@sudarmuthu) Research Engineer, Yahoo! Labs http://hardwarefun.com http://github.com/sudar
  • 2. Who am I?  Research Engineer by profession  Creates robots as hobby  Prefers Arduino  Prefers JavaScript at work  Why not combine both of them?  .. and that’s what I am going to talk about today
  • 3. Why hardware for a software hacker? Fun!
  • 4. Let’s start with a demo Demo http://hardwarefun.com/projects/asimijs
  • 5. Participate in the demo  Visit http://hardwarefun.com:3000
  • 6. Control the bot at stage http://hardwarefun.com/projects/asimijs #asimijs @hardwarefun
  • 7. Arduino  Visual Basic for hardware  Includes both Hardware and software Photo credit Arduino team
  • 8. Interfacing Arduino with JavaScript  Using serial connection (node-serialport)  Using abstraction (like johnny-five or duino)  Using serial Bluetooth connection (asimijs)
  • 9. Using Serial Connection You need node-serialport - https://github.com/voodootikigod/node-serialport var SerialPort = require("serialport").SerialPort, arduino = new SerialPort("/dev/tty/ACM1"); // when data is received from arduino arduino.on("data", function (data) { arduino.write(new Buffer[data]); console.log("Got: " + data); }); // if there was any error arduino.on("error", function (data) { console.log("Error: " + data); });
  • 10. Using Abstraction  Build on top of node-serialport - https://github.com/voodootikigod/node-serialport  Options include Johnny-five - https://github.com/rwldrn/johnny-five and duino - https://github.com/ecto/duino  Load the firmdata program into Arduino  It provides the necessary abstraction  Write code using a node.js library  Profit 
  • 12. Code var five = require("johnny-five"), board = new five.Board(); board.on("ready", function() { // Create an Led on pin 13 (new five.Led(13)).strobe(1000); });
  • 14. Reading sensor data What you need? Any sensor and a LED
  • 15. Reading sensor data var five = require("johnny-five"), board, led, photoresistor; board = new five.Board(); board.on("ready", function() { // Create a new `photoresistor` hardware instance. photoresistor = new five.Sensor({pin: "A2”, freq: 250}); led = new five.Led(13); // "read" get the current reading from the photoresistor photoresistor.on("read", function( err, value ) { if (value > 50) { led.on(); } else { led.off(); } console.log( value, this.normalized ); }); // Inject the `sensor` hardware into the Repl instance's context; // allows direct command line access board.repl.inject({ pot: photoresistor }); });
  • 16. Using serial Bluetooth connection  Bluetooth shield gives wireless capability to Arduino  A Bluetooth connection appears as serial port in your computer  Using node-serialport you can talk wirelessly to Arduino  And that’s what I did for demo ;)
  • 17. Using serial Bluetooth connection var SerialPort = require("serialport").SerialPort, bt = new SerialPort("/dev/cu.FireFly-CCFA-SPP"); // when data is received from bluetooth bt.on("data", function (data) { bt.write(new Buffer[data]); console.log("Got: " + data); }); // error reading bluetooth serial port bt.on("error", function (data) { console.log("Error: " + data); });
  • 18. How the demo worked Node.js Server Node Client Admin page User page User page User page
  • 19. Links  AsimiJS – The demo that I showed initially http://hardwarefun.com/projects/asimijs  Asimi – A simple bot using Arduino http://hardwarefun.com/project/asimi  Getting started with hardware programming http://hardwarefun.com/tutorials/getting-started-with- hardware-programming  Getting started with Arduino http://hardwarefun.com/tutorials/getting-started-with-arduino- and-avr  Node-serialport https://github.com/voodootikigod/node- serialport  Johnny Five https://github.com/rwldrn/johnny-five
  • 20. Questions Thank You Sudar Muthu (@sudarmuthu) http://hardwarefun.com http://gitbub.com/sudar