Arduino Node
Arduino Node
ArduinoNode.jsRCCarDrivenwiththeHTML5GamepadAPI
Back
Blog Resources
http://www.webondevices.com/arduinonodejsrccardrivenwithhtml5gamepadapi/
1/8
22/9/2016
ArduinoNode.jsRCCarDrivenwiththeHTML5GamepadAPI
I started the project o by experimenting with reading raw data from USB joysticks,
Back and racing wheels from the browser. This is a relatively easy
Blog
gamepads
taskResources
in
browsers supporting the HTML5 Gamepad API:
Download FREE Ebook: Introduction to JavaScript Electronics
varrawGamepads=
(navigator.getGamepads&&navigator.getGamepads())||
(navigator.webkitGetGamepads&&navigator.webkitGetGamepads());
http://www.webondevices.com/arduinonodejsrccardrivenwithhtml5gamepadapi/
2/8
22/9/2016
ArduinoNode.jsRCCarDrivenwiththeHTML5GamepadAPI
myGamepad=gamepadSupport.gamepads[0];
Back
//Steering:
Blog Resources
myGamepad.axes[0];
Download FREE Ebook: Introduction to JavaScript Electronics
//Acceleration:
myGamepad.axes[1];
//Breaking:
myGamepad.axes[2];
//Buttonsfrom012:
myGamepad.buttons[0]
varapp=require('express')(),
server=require('http').createServer(app).listen(8080);
//respondtowebGETrequestswiththeindex.htmlpage:
app.get('/',function(request,response){
response.sendfile(__dirname+'/index.html');
});
vario=require('socket.io').listen(server);
//listenfornewsocket.ioconnections
//wedon'tstartreadinganytinguntilthebrowserhasconnected
io.sockets.on('connection',function(socket){
socket.on('message',function(data){
http://www.webondevices.com/arduinonodejsrccardrivenwithhtml5gamepadapi/
3/8
22/9/2016
ArduinoNode.jsRCCarDrivenwiththeHTML5GamepadAPI
//datasentfromthebrowser
Back
console.log(data);
});
});
Blog Resources
//dataStringistheJSONwiththewheelandpedalcontroldata
socket.emit('message',dataString);
//opentheUSBserialport
varmyPort=newSerialPort("/dev/tty.usbmodem1421",{
//lookforreturnandnewlineattheendofeachdatapacket
parser:serialport.parsers.readline("\r\n")
});
myPort.write(messageReceivedFromTheBrowser);
The RC car
The work has started o by taking out the original radio and motor drive modules
and the antenna from the car. I was left with two motors, one for steering and one
for acceleration, and the plan was to rebuild the whole architecture using Arduinos. I
succeeded and the motors are now driven with a powerful H-bridge module (L298n)
and the wireless connection is handled by two nRF24l01 antennas. The Arduino and
the motors are both powered from the original 6V battery pack (4xAA).
http://www.webondevices.com/arduinonodejsrccardrivenwithhtml5gamepadapi/
4/8
22/9/2016
ArduinoNode.jsRCCarDrivenwiththeHTML5GamepadAPI
Back
Blog Resources
The guts of the car: Arduino Nano, antenna, motor control unit
The onboard Arduino Nano receives wireless messages from the Arduino UNO
connected to the my Macbook Pro which is the one communicating with the Node.js
server and the browser.
Future plans
There are so many parts of this projects that are really exciting and interesting and
parts that are a little bit more dicult to fully implement. So please let me know and
leave a comment if you want me to create and extended tutorial on this project!
http://www.webondevices.com/arduinonodejsrccardrivenwithhtml5gamepadapi/
5/8
22/9/2016
ArduinoNode.jsRCCarDrivenwiththeHTML5GamepadAPI
Back
Blog Resources
Steve says:
July 23, 2015 at 9:13 pm
Please give us more information on how you did this project. For instance,
how was the controller card determined? It looks extremely complicated
a multi-part tutorial.
http://www.webondevices.com/arduinonodejsrccardrivenwithhtml5gamepadapi/
6/8
22/9/2016
ArduinoNode.jsRCCarDrivenwiththeHTML5GamepadAPI
Back
July 24, 2015 at 4:19 am
Blog Resources
Martin,
Download
Ebook: Introduction
JavaScript
Electronics
thanks forFREE
the comment
and interest.toThe
Ebook Im
currently writing is
going to be a lot of help for complete beginners. It will get you started
with all the basics in a couple of hours and you will straight away
understand all the projects on my website. The same time a complete
tutorial would also help, just to see every single line of code, with a lot
more photos, so I will work on that too!
Leave a Reply
You must be logged in to post a comment.
http://www.webondevices.com/arduinonodejsrccardrivenwithhtml5gamepadapi/
7/8
22/9/2016
ArduinoNode.jsRCCarDrivenwiththeHTML5GamepadAPI
Back
Blog Resources
FreeDownload
Ebook
FREE Ebook: Introduction to JavaScript Electronics
Step up your web developer career and learn hardware prototyping.
This ebook will get you started with JavaScript Arduino electronics development in a
couple of hours.
Email address
Web on Devices
Electronics Hacking with JavaScript and other Web Technologies
Twitter
Mate Marschalko
Front-end Web Developer, Creative Technologist and Maker. Builds Internet connected devices for the Internet of
Things.
8/8