SlideShare a Scribd company logo
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

What's hot

My Robot Poops - In JavaScript (with web sockets)
My Robot Poops - In JavaScript (with web sockets)My Robot Poops - In JavaScript (with web sockets)
My Robot Poops - In JavaScript (with web sockets)
Matthew Schiffman
 

What's hot (13)

JavaScript in the Real World
JavaScript in the Real WorldJavaScript in the Real World
JavaScript in the Real World
 
Vi
ViVi
Vi
 
My Robot Poops - In JavaScript (with web sockets)
My Robot Poops - In JavaScript (with web sockets)My Robot Poops - In JavaScript (with web sockets)
My Robot Poops - In JavaScript (with web sockets)
 
Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin
 
Couverture de code
Couverture de codeCouverture de code
Couverture de code
 
Mojolicious lite
Mojolicious liteMojolicious lite
Mojolicious lite
 
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an...
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 (iOS User Group Berlin)Continuous Integration for iOS (iOS User Group Berlin)
Continuous Integration for iOS (iOS User Group Berlin)
 
Continuous Integration for iOS
Continuous Integration for iOSContinuous Integration for iOS
Continuous Integration for iOS
 
Bundler is the Best
Bundler is the BestBundler is the Best
Bundler is the Best
 
CasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated TestingCasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated Testing
 
Let's begin io t with $10
Let's begin io t with $10Let's begin io t with $10
Let's begin io t with $10
 
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can !
 

Similar to Controlling robots using javascript

Similar to Controlling robots using javascript (20)

Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of things
 
BURO Arduino Workshop
BURO Arduino WorkshopBURO Arduino Workshop
BURO Arduino Workshop
 
Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!
 
Javascript robotics
Javascript roboticsJavascript robotics
Javascript robotics
 
IoT on Raspberry Pi
IoT on Raspberry PiIoT on Raspberry Pi
IoT on Raspberry Pi
 
Setting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with AppiumSetting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with Appium
 
Programming objects with android
Programming objects with androidProgramming objects with android
Programming objects with android
 
Hardware Hacking
Hardware HackingHardware Hacking
Hardware Hacking
 
Lets make robots
Lets make robotsLets make robots
Lets make robots
 
Exploring the Internet of Things Using Ruby
Exploring the Internet of Things Using RubyExploring the Internet of Things Using Ruby
Exploring the Internet of Things Using Ruby
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
 
Arduino
ArduinoArduino
Arduino
 
IoT with openHAB on pcDuino3B
IoT with openHAB on pcDuino3BIoT with openHAB on pcDuino3B
IoT with openHAB on pcDuino3B
 
Setting UIAutomation free with Appium
Setting UIAutomation free with AppiumSetting UIAutomation free with Appium
Setting UIAutomation free with Appium
 
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
 
Building your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry PiBuilding your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry Pi
 
Arduino Development For Beginners
Arduino Development For BeginnersArduino Development For Beginners
Arduino Development For Beginners
 
Programming the Real World: Javascript for Makers
Programming the Real World: Javascript for MakersProgramming the Real World: Javascript for Makers
Programming the Real World: Javascript for Makers
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
 

More from Sudar Muthu

Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)
Sudar Muthu
 

More from Sudar Muthu (20)

A quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress MeetupA quick preview of WP CLI - Chennai WordPress Meetup
A quick preview of WP CLI - Chennai WordPress Meetup
 
WordPress Developer tools
WordPress Developer toolsWordPress Developer tools
WordPress Developer tools
 
WordPress Developer Tools to increase productivity
WordPress Developer Tools to increase productivityWordPress Developer Tools to increase productivity
WordPress Developer Tools to increase productivity
 
Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPress
 
Unit testing in php
Unit testing in phpUnit testing in php
Unit testing in php
 
How arduino helped me in life
How arduino helped me in lifeHow arduino helped me in life
How arduino helped me in life
 
Having fun with hardware
Having fun with hardwareHaving fun with hardware
Having fun with hardware
 
Getting started with arduino workshop
Getting started with arduino workshopGetting started with arduino workshop
Getting started with arduino workshop
 
Python in raspberry pi
Python in raspberry piPython in raspberry pi
Python in raspberry pi
 
Hack 101 at IIT Kanpur
Hack 101 at IIT KanpurHack 101 at IIT Kanpur
Hack 101 at IIT Kanpur
 
PureCSS open hack 2013
PureCSS open hack 2013PureCSS open hack 2013
PureCSS open hack 2013
 
Pig workshop
Pig workshopPig workshop
Pig workshop
 
Arduino Robotics workshop day2
Arduino Robotics workshop day2Arduino Robotics workshop day2
Arduino Robotics workshop day2
 
Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Arduino Robotics workshop Day1
Arduino Robotics workshop Day1
 
Hands on Hadoop and pig
Hands on Hadoop and pigHands on Hadoop and pig
Hands on Hadoop and pig
 
Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)
 
Picture perfect hacks with flickr API
Picture perfect hacks with flickr APIPicture perfect hacks with flickr API
Picture perfect hacks with flickr API
 
Hacking 101
Hacking 101Hacking 101
Hacking 101
 
Capabilities of Arduino
Capabilities of ArduinoCapabilities of Arduino
Capabilities of Arduino
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 

Recently uploaded

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Recently uploaded (20)

A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 

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