Controlling robots using javascript
Upcoming SlideShare
Loading in...5
×
 

Controlling robots using javascript

on

  • 5,266 views

Controlling Robots using JavaScript. Slides from my talk at jsfoo. Details at http://sudarmuthu.com/blog/controlling-robots-using-javascript

Controlling Robots using JavaScript. Slides from my talk at jsfoo. Details at http://sudarmuthu.com/blog/controlling-robots-using-javascript

Statistics

Views

Total Views
5,266
Views on SlideShare
5,029
Embed Views
237

Actions

Likes
4
Downloads
47
Comments
0

7 Embeds 237

https://hasgeek.tv 147
http://funnel.hasgeek.com 49
https://funnel.hasgeek.com 14
http://hasgeek.tv 12
http://localhost 12
http://eventifier.co 2
https://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Controlling robots using javascript Controlling robots using javascript Presentation Transcript

  • 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 ConnectionYou need node-serialport - https://github.com/voodootikigod/node-serialportvar SerialPort = require("serialport").SerialPort, arduino = new SerialPort("/dev/tty/ACM1");// when data is received from arduinoarduino.on("data", function (data) { arduino.write(new Buffer[data]); console.log("Got: " + data);});// if there was any errorarduino.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 
  • DemoLet there be LIGHT
  • Codevar 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 datavar 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 instances 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 connectionvar SerialPort = require("serialport").SerialPort, bt = new SerialPort("/dev/cu.FireFly-CCFA-SPP");// when data is received from bluetoothbt.on("data", function (data) { bt.write(new Buffer[data]); console.log("Got: " + data);});// error reading bluetooth serial portbt.on("error", function (data) { console.log("Error: " + data);});
  • How the demo worked Node.js Server Node ClientAdmin 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
  • QuestionsThank YouSudar Muthu (@sudarmuthu) http://hardwarefun.com http://gitbub.com/sudar