Controlling robots using javascript

Sudar Muthu
Sudar MuthuIndependent Consultant
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
1 of 20

Recommended

Android and Arduio mixed with Breakout js by
Android and Arduio mixed with Breakout jsAndroid and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout jsmusart Park
23.5K views16 slides
Home sensor prototype on Arduino & Raspberry Pi with Node.JS by
Home sensor prototype on Arduino & Raspberry Pi with Node.JSHome sensor prototype on Arduino & Raspberry Pi with Node.JS
Home sensor prototype on Arduino & Raspberry Pi with Node.JSHyunghun Cho
7.7K views18 slides
Js robotics by
Js roboticsJs robotics
Js roboticsStamo Petkov
755 views32 slides
[H3 2012] 우리가 모르는 Node.js로 할 수 있는 몇가지 by
[H3 2012] 우리가 모르는 Node.js로 할 수 있는 몇가지[H3 2012] 우리가 모르는 Node.js로 할 수 있는 몇가지
[H3 2012] 우리가 모르는 Node.js로 할 수 있는 몇가지KTH, 케이티하이텔
5.8K views46 slides
Build Lifecycle Craftsmanship for the Transylvania JUG by
Build Lifecycle Craftsmanship for the Transylvania JUGBuild Lifecycle Craftsmanship for the Transylvania JUG
Build Lifecycle Craftsmanship for the Transylvania JUGMatthew McCullough
464 views71 slides

More Related Content

What's hot

JavaScript in the Real World by
JavaScript in the Real WorldJavaScript in the Real World
JavaScript in the Real WorldAndrew Nesbitt
1.3K views79 slides
Vi by
ViVi
Viluanpho91
111 views1 slide
My Robot Poops - In JavaScript (with web sockets) by
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
520 views112 slides
Why use JavaScript in Hardware? GoTo Conf - Berlin by
Why use JavaScript in Hardware? GoTo Conf - Berlin Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin TechnicalMachine
1.1K views40 slides
Couverture de code by
Couverture de codeCouverture de code
Couverture de codeCocoaHeads France
6.8K views67 slides
Mojolicious lite by
Mojolicious liteMojolicious lite
Mojolicious liteandrefsantos
1.3K views32 slides

What's hot(13)

JavaScript in the Real World by Andrew Nesbitt
JavaScript in the Real WorldJavaScript in the Real World
JavaScript in the Real World
Andrew Nesbitt1.3K views
My Robot Poops - In JavaScript (with web sockets) by Matthew Schiffman
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 Schiffman520 views
Why use JavaScript in Hardware? GoTo Conf - Berlin by TechnicalMachine
Why use JavaScript in Hardware? GoTo Conf - Berlin Why use JavaScript in Hardware? GoTo Conf - Berlin
Why use JavaScript in Hardware? GoTo Conf - Berlin
TechnicalMachine1.1K views
Infinum Android Talks #20 - Making your Android apps fast like Blue Runner an... by Infinum
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...
Infinum497 views
Continuous Integration for iOS (iOS User Group Berlin) by Wooga
Continuous Integration for iOS (iOS User Group Berlin)Continuous Integration for iOS (iOS User Group Berlin)
Continuous Integration for iOS (iOS User Group Berlin)
Wooga1.6K views
Continuous Integration for iOS by Mattes Groeger
Continuous Integration for iOSContinuous Integration for iOS
Continuous Integration for iOS
Mattes Groeger723 views
Bundler is the Best by dead_arm
Bundler is the BestBundler is the Best
Bundler is the Best
dead_arm893 views
CasperJS and PhantomJS for Automated Testing by X-Team
CasperJS and PhantomJS for Automated TestingCasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated Testing
X-Team1.1K views
Devoxx France: Développement JAVA avec un IDE dans le Cloud: Yes we can ! by Florent BENOIT
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 !
Florent BENOIT1.2K views

Similar to Controlling robots using javascript

Using arduino and raspberry pi for internet of things by
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 thingsSudar Muthu
7.4K views69 slides
BURO Arduino Workshop by
BURO Arduino WorkshopBURO Arduino Workshop
BURO Arduino WorkshopOmer Kilic
3.8K views52 slides
Lab Handson: Power your Creations with Intel Edison! by
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!Codemotion
2K views66 slides
Javascript robotics by
Javascript roboticsJavascript robotics
Javascript roboticsIbnu Triyono
69 views13 slides
IoT on Raspberry Pi by
IoT on Raspberry PiIoT on Raspberry Pi
IoT on Raspberry PiJohn Staveley
229 views37 slides
Setting Apple's UI Automation Free with Appium by
Setting Apple's UI Automation Free with AppiumSetting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with Appiummobiletestsummit
7.9K views19 slides

Similar to Controlling robots using javascript(20)

Using arduino and raspberry pi for internet of things by Sudar Muthu
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
Sudar Muthu7.4K views
BURO Arduino Workshop by Omer Kilic
BURO Arduino WorkshopBURO Arduino Workshop
BURO Arduino Workshop
Omer Kilic3.8K views
Lab Handson: Power your Creations with Intel Edison! by Codemotion
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!
Codemotion2K views
Setting Apple's UI Automation Free with Appium by mobiletestsummit
Setting Apple's UI Automation Free with AppiumSetting Apple's UI Automation Free with Appium
Setting Apple's UI Automation Free with Appium
mobiletestsummit7.9K views
Programming objects with android by firenze-gtug
Programming objects with androidProgramming objects with android
Programming objects with android
firenze-gtug2.6K views
Lets make robots by Sudar Muthu
Lets make robotsLets make robots
Lets make robots
Sudar Muthu2.7K views
Exploring the Internet of Things Using Ruby by Mike Hagedorn
Exploring the Internet of Things Using RubyExploring the Internet of Things Using Ruby
Exploring the Internet of Things Using Ruby
Mike Hagedorn2.5K views
pcDuino Presentation at SparkFun by Jingfeng Liu
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
Jingfeng Liu2.4K views
Porting your favourite cmdline tool to Android by Vlatko Kosturjak
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
Vlatko Kosturjak1.3K views
IoT with openHAB on pcDuino3B by Jingfeng Liu
IoT with openHAB on pcDuino3BIoT with openHAB on pcDuino3B
IoT with openHAB on pcDuino3B
Jingfeng Liu3.7K views
Setting UIAutomation free with Appium by Dan Cuellar
Setting UIAutomation free with AppiumSetting UIAutomation free with Appium
Setting UIAutomation free with Appium
Dan Cuellar643 views
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ... by Mark West
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 ...
Mark West1.9K views
Building your own RC Car with Raspberry Pi by Jeff Prestes
Building your own RC Car with Raspberry PiBuilding your own RC Car with Raspberry Pi
Building your own RC Car with Raspberry Pi
Jeff Prestes10.2K views
Arduino Development For Beginners by FTS seminar
Arduino Development For BeginnersArduino Development For Beginners
Arduino Development For Beginners
FTS seminar12.2K views
Programming the Real World: Javascript for Makers by pchristensen
Programming the Real World: Javascript for MakersProgramming the Real World: Javascript for Makers
Programming the Real World: Javascript for Makers
pchristensen11.5K views
Getting started with Intel IoT Developer Kit by Sulamita Garcia
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
Sulamita Garcia17.8K views

More from Sudar Muthu

A quick preview of WP CLI - Chennai WordPress Meetup by
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 MeetupSudar Muthu
1.5K views8 slides
WordPress Developer tools by
WordPress Developer toolsWordPress Developer tools
WordPress Developer toolsSudar Muthu
9.1K views23 slides
WordPress Developer Tools to increase productivity by
WordPress Developer Tools to increase productivityWordPress Developer Tools to increase productivity
WordPress Developer Tools to increase productivitySudar Muthu
2.1K views23 slides
Unit testing for WordPress by
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPressSudar Muthu
5.2K views27 slides
Unit testing in php by
Unit testing in phpUnit testing in php
Unit testing in phpSudar Muthu
2.1K views19 slides
How arduino helped me in life by
How arduino helped me in lifeHow arduino helped me in life
How arduino helped me in lifeSudar Muthu
2.8K views16 slides

More from Sudar Muthu(20)

A quick preview of WP CLI - Chennai WordPress Meetup by Sudar Muthu
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
Sudar Muthu1.5K views
WordPress Developer tools by Sudar Muthu
WordPress Developer toolsWordPress Developer tools
WordPress Developer tools
Sudar Muthu9.1K views
WordPress Developer Tools to increase productivity by Sudar Muthu
WordPress Developer Tools to increase productivityWordPress Developer Tools to increase productivity
WordPress Developer Tools to increase productivity
Sudar Muthu2.1K views
Unit testing for WordPress by Sudar Muthu
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPress
Sudar Muthu5.2K views
Unit testing in php by Sudar Muthu
Unit testing in phpUnit testing in php
Unit testing in php
Sudar Muthu2.1K views
How arduino helped me in life by Sudar Muthu
How arduino helped me in lifeHow arduino helped me in life
How arduino helped me in life
Sudar Muthu2.8K views
Having fun with hardware by Sudar Muthu
Having fun with hardwareHaving fun with hardware
Having fun with hardware
Sudar Muthu2.6K views
Getting started with arduino workshop by Sudar Muthu
Getting started with arduino workshopGetting started with arduino workshop
Getting started with arduino workshop
Sudar Muthu3.6K views
Python in raspberry pi by Sudar Muthu
Python in raspberry piPython in raspberry pi
Python in raspberry pi
Sudar Muthu8K views
Hack 101 at IIT Kanpur by Sudar Muthu
Hack 101 at IIT KanpurHack 101 at IIT Kanpur
Hack 101 at IIT Kanpur
Sudar Muthu1.7K views
PureCSS open hack 2013 by Sudar Muthu
PureCSS open hack 2013PureCSS open hack 2013
PureCSS open hack 2013
Sudar Muthu3.7K views
Arduino Robotics workshop day2 by Sudar Muthu
Arduino Robotics workshop day2Arduino Robotics workshop day2
Arduino Robotics workshop day2
Sudar Muthu9.5K views
Arduino Robotics workshop Day1 by Sudar Muthu
Arduino Robotics workshop Day1Arduino Robotics workshop Day1
Arduino Robotics workshop Day1
Sudar Muthu12.8K views
Hands on Hadoop and pig by Sudar Muthu
Hands on Hadoop and pigHands on Hadoop and pig
Hands on Hadoop and pig
Sudar Muthu2.6K views
Capabilities of Arduino (including Due) by Sudar Muthu
Capabilities of Arduino (including Due)Capabilities of Arduino (including Due)
Capabilities of Arduino (including Due)
Sudar Muthu2.8K views
Picture perfect hacks with flickr API by Sudar Muthu
Picture perfect hacks with flickr APIPicture perfect hacks with flickr API
Picture perfect hacks with flickr API
Sudar Muthu2.7K views
Capabilities of Arduino by Sudar Muthu
Capabilities of ArduinoCapabilities of Arduino
Capabilities of Arduino
Sudar Muthu5.7K views
Introduction to node.js GDD by Sudar Muthu
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
Sudar Muthu7.3K views

Recently uploaded

CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueShapeBlue
63 views15 slides
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...ShapeBlue
105 views15 slides
State of the Union - Rohit Yadav - Apache CloudStack by
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStackShapeBlue
218 views53 slides
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
75 views23 slides
NTGapps NTG LowCode Platform by
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform Mustafa Kuğu
287 views30 slides
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveNetwork Automation Forum
49 views35 slides

Recently uploaded(20)

CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue63 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue105 views
State of the Union - Rohit Yadav - Apache CloudStack by ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue218 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue75 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu287 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue69 views
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue59 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays49 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue134 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue191 views
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue74 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue110 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE67 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue149 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue93 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely76 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue120 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue48 views

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