SlideShare a Scribd company logo
1 of 18
Download to read offline
Little bits & node.js
IOT for beginner
Michele Capra
!
@piccoloaiutante
!
michele.capra@nearform.com
Summary
• Little bits
• Arduino
• Node.js
• Demo
• Q&A
Little bits
• Modular electronic components that
snap together via magnetic connectors
• Designed for education
• Arduino coding kit
Arduino coding kit
• 1 x arduino
• 1 x fork
• 1 x power
• 1 x button
• 2 x dimmer
• 1 x bargraph
• 1 x servo
Arduino
It's an open-source physical computing platform based on a simple
microcontroller board, and a development environment for writing
software for the board
Node.js & johnny-
five
• johnny-five is an Open Source, Firmata
Protocol based, IoT and Robotics
programming framework
• “..johnny-five wants to be a baseline
control kit for hardware projects,
allowing you the freedom to build,
grow and experiment with diverse
JavaScript libraries of your own
choice..”
Setting up Arduino
board
!
• Connect the Arduino module to the
computer using USB
• Connect power module because the
Arduino module is not powered via USB.
• Upload StandardFirmata to Arduino
board using the Arduino IDE
Demo
• Using dimmers to draw to the screen
just like an Etch-a-sketch.
Little bits in
action
• 1x Arduino
• 1x power
• 1 x fork
• 2 x dimmers
• 1 x button
The circuit
Code
• Webpage as web interface for our etch-
a-sketch (HTML5 canvas + socket.io)
• Node webserver that will read the X
and Y values from dimmers and
communicate to our client
(socket.io + johnny-five)
Server code
board.on("ready", function() {
!
joystick = new five.Joystick({
pins: ["A1", "A0"],
freq: 100
});
button=new five.Button(0);
Server code
html = fs.readFileSync('draw.html').toString();
!
server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(html);
});
Server code
io.listen(server).on('connection', function (socket) {
// send the X, Y values to the client
joystick.on("axismove", function(err, timestamp) {
console.log(this.fixed.x, this.fixed.y);
socket.emit('drawing', this.fixed);
});
!
button.on("press", function(value){
socket.emit('clear');
});
});
Client code
!
socket.on('clear', function(){
context.clearRect(0,0,600,400);
context.beginPath();
});
!
socket.on('drawing', function (data) {
$('#status').html('Connected (x: ' + data.x +
', y: ' + data.y + ')');
// scale values to match canvas size
data.x *= 600;
data.y *= 400;
// if values have changed, draw a line to the new position
if (prev && (prev.x != data.x || prev.y != data.y)) {
context.moveTo(prev.x, prev.y);
context.lineTo(data.x, data.y);
context.stroke();
}
prev = data;
});
Demo time
That’s all
Credits
• little-bits-js:Anna Gerber has created
several exercise that you could do
with little bits, included the etch-a-
sketch that you’ve seen (https://
github.com/AnnaGerber/little-bits-js)
• Images of bits used in this
presentation have been sourced from
littlebits.cc and used under a
Creative Commons CC-BY-SA license.

More Related Content

Similar to Little bits & node.js IOT for beginner

Using OSVR to Support (practically) Any Device in VR/AR
Using OSVR to Support (practically) Any Device in VR/ARUsing OSVR to Support (practically) Any Device in VR/AR
Using OSVR to Support (practically) Any Device in VR/ARYuval Boger
 
Android and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout jsAndroid and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout jsmusart Park
 
Overview of the Intel® Internet of Things Developer Kit
Overview of the Intel® Internet of Things Developer KitOverview of the Intel® Internet of Things Developer Kit
Overview of the Intel® Internet of Things Developer KitIntel® Software
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractionsAkshar Desai
 
Massively Social != Massively Multiplayer
Massively Social != Massively MultiplayerMassively Social != Massively Multiplayer
Massively Social != Massively MultiplayerPaul Furio
 
Electric Imp - Hackathon Intro
Electric Imp - Hackathon IntroElectric Imp - Hackathon Intro
Electric Imp - Hackathon IntroMatt Haines
 
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 ...Mark West
 
IoT Node-Red Presentation
IoT  Node-Red PresentationIoT  Node-Red Presentation
IoT Node-Red PresentationThe IOT Academy
 
Robots conf microcontroller and iot survey
Robots conf   microcontroller and iot surveyRobots conf   microcontroller and iot survey
Robots conf microcontroller and iot surveyMatt Haines
 
DIY IoT: Raspberry PI 2 + Windows 10 for IoT devices + Microsoft Azure
DIY IoT: Raspberry PI 2 + Windows 10 for IoT devices + Microsoft AzureDIY IoT: Raspberry PI 2 + Windows 10 for IoT devices + Microsoft Azure
DIY IoT: Raspberry PI 2 + Windows 10 for IoT devices + Microsoft AzureIntersog
 
Building a Thought Controlled Drone
Building a Thought Controlled DroneBuilding a Thought Controlled Drone
Building a Thought Controlled DroneJim McKeeth
 
Hacking with the Raspberry Pi and Windows 10 IoT Core
Hacking with the Raspberry Pi and Windows 10 IoT CoreHacking with the Raspberry Pi and Windows 10 IoT Core
Hacking with the Raspberry Pi and Windows 10 IoT CoreNick Landry
 
How To Electrocute Yourself using the Internet
How To Electrocute Yourself using the InternetHow To Electrocute Yourself using the Internet
How To Electrocute Yourself using the InternetAlexander Roche
 
Controlling your home with IoT Hub
Controlling your home with IoT HubControlling your home with IoT Hub
Controlling your home with IoT HubStamatis Pavlis
 
Internet of Things 101 - Part II
Internet of Things 101 - Part IIInternet of Things 101 - Part II
Internet of Things 101 - Part IIYoonseok Hur
 

Similar to Little bits & node.js IOT for beginner (20)

Using OSVR to Support (practically) Any Device in VR/AR
Using OSVR to Support (practically) Any Device in VR/ARUsing OSVR to Support (practically) Any Device in VR/AR
Using OSVR to Support (practically) Any Device in VR/AR
 
Android and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout jsAndroid and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout js
 
Overview of the Intel® Internet of Things Developer Kit
Overview of the Intel® Internet of Things Developer KitOverview of the Intel® Internet of Things Developer Kit
Overview of the Intel® Internet of Things Developer Kit
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractions
 
Massively Social != Massively Multiplayer
Massively Social != Massively MultiplayerMassively Social != Massively Multiplayer
Massively Social != Massively Multiplayer
 
Electric Imp - Hackathon Intro
Electric Imp - Hackathon IntroElectric Imp - Hackathon Intro
Electric Imp - Hackathon Intro
 
Node azure
Node azureNode azure
Node azure
 
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 ...
 
IOT beginnners
IOT beginnnersIOT beginnners
IOT beginnners
 
IOT beginnners
IOT beginnnersIOT beginnners
IOT beginnners
 
IoT Node-Red Presentation
IoT  Node-Red PresentationIoT  Node-Red Presentation
IoT Node-Red Presentation
 
Robots conf microcontroller and iot survey
Robots conf   microcontroller and iot surveyRobots conf   microcontroller and iot survey
Robots conf microcontroller and iot survey
 
Tablet pc
Tablet pcTablet pc
Tablet pc
 
DIY IoT: Raspberry PI 2 + Windows 10 for IoT devices + Microsoft Azure
DIY IoT: Raspberry PI 2 + Windows 10 for IoT devices + Microsoft AzureDIY IoT: Raspberry PI 2 + Windows 10 for IoT devices + Microsoft Azure
DIY IoT: Raspberry PI 2 + Windows 10 for IoT devices + Microsoft Azure
 
Building a Thought Controlled Drone
Building a Thought Controlled DroneBuilding a Thought Controlled Drone
Building a Thought Controlled Drone
 
Hacking with the Raspberry Pi and Windows 10 IoT Core
Hacking with the Raspberry Pi and Windows 10 IoT CoreHacking with the Raspberry Pi and Windows 10 IoT Core
Hacking with the Raspberry Pi and Windows 10 IoT Core
 
How To Electrocute Yourself using the Internet
How To Electrocute Yourself using the InternetHow To Electrocute Yourself using the Internet
How To Electrocute Yourself using the Internet
 
Controlling your home with IoT Hub
Controlling your home with IoT HubControlling your home with IoT Hub
Controlling your home with IoT Hub
 
Internet of Things 101 - Part II
Internet of Things 101 - Part IIInternet of Things 101 - Part II
Internet of Things 101 - Part II
 
Edge Of The Web
Edge Of The WebEdge Of The Web
Edge Of The Web
 

More from Michele Capra

Nodeschool italy at codemotion
Nodeschool italy at codemotionNodeschool italy at codemotion
Nodeschool italy at codemotionMichele Capra
 
Testing Windows Phone 8.1 app with unit test and Coded UI test
Testing Windows Phone 8.1 app with unit test and Coded UI testTesting Windows Phone 8.1 app with unit test and Coded UI test
Testing Windows Phone 8.1 app with unit test and Coded UI testMichele Capra
 
Porting business apps to Windows Phone
Porting business apps to Windows PhonePorting business apps to Windows Phone
Porting business apps to Windows PhoneMichele Capra
 
The magic of Dynamic in Nancy Fx
The magic of Dynamic in Nancy FxThe magic of Dynamic in Nancy Fx
The magic of Dynamic in Nancy FxMichele Capra
 
Building High Performance and Reliable Windows Phone 8 Apps
Building High Performance and Reliable Windows Phone 8 AppsBuilding High Performance and Reliable Windows Phone 8 Apps
Building High Performance and Reliable Windows Phone 8 AppsMichele Capra
 
Test and profile your Windows Phone 8 App
Test and profile your Windows Phone 8 AppTest and profile your Windows Phone 8 App
Test and profile your Windows Phone 8 AppMichele Capra
 
Getting started with Windows Phone 7 and unit test
Getting started with Windows Phone 7 and unit testGetting started with Windows Phone 7 and unit test
Getting started with Windows Phone 7 and unit testMichele Capra
 
Introduzione a Node.js
Introduzione a Node.jsIntroduzione a Node.js
Introduzione a Node.jsMichele Capra
 
Developing application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDDDeveloping application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDDMichele Capra
 
Windows Phone 7 Development
Windows Phone 7 DevelopmentWindows Phone 7 Development
Windows Phone 7 DevelopmentMichele Capra
 
My Final Dissertation
My Final DissertationMy Final Dissertation
My Final DissertationMichele Capra
 

More from Michele Capra (11)

Nodeschool italy at codemotion
Nodeschool italy at codemotionNodeschool italy at codemotion
Nodeschool italy at codemotion
 
Testing Windows Phone 8.1 app with unit test and Coded UI test
Testing Windows Phone 8.1 app with unit test and Coded UI testTesting Windows Phone 8.1 app with unit test and Coded UI test
Testing Windows Phone 8.1 app with unit test and Coded UI test
 
Porting business apps to Windows Phone
Porting business apps to Windows PhonePorting business apps to Windows Phone
Porting business apps to Windows Phone
 
The magic of Dynamic in Nancy Fx
The magic of Dynamic in Nancy FxThe magic of Dynamic in Nancy Fx
The magic of Dynamic in Nancy Fx
 
Building High Performance and Reliable Windows Phone 8 Apps
Building High Performance and Reliable Windows Phone 8 AppsBuilding High Performance and Reliable Windows Phone 8 Apps
Building High Performance and Reliable Windows Phone 8 Apps
 
Test and profile your Windows Phone 8 App
Test and profile your Windows Phone 8 AppTest and profile your Windows Phone 8 App
Test and profile your Windows Phone 8 App
 
Getting started with Windows Phone 7 and unit test
Getting started with Windows Phone 7 and unit testGetting started with Windows Phone 7 and unit test
Getting started with Windows Phone 7 and unit test
 
Introduzione a Node.js
Introduzione a Node.jsIntroduzione a Node.js
Introduzione a Node.js
 
Developing application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDDDeveloping application for Windows Phone 7 in TDD
Developing application for Windows Phone 7 in TDD
 
Windows Phone 7 Development
Windows Phone 7 DevelopmentWindows Phone 7 Development
Windows Phone 7 Development
 
My Final Dissertation
My Final DissertationMy Final Dissertation
My Final Dissertation
 

Recently uploaded

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Recently uploaded (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

Little bits & node.js IOT for beginner

  • 1. Little bits & node.js IOT for beginner Michele Capra ! @piccoloaiutante ! michele.capra@nearform.com
  • 2. Summary • Little bits • Arduino • Node.js • Demo • Q&A
  • 3. Little bits • Modular electronic components that snap together via magnetic connectors • Designed for education • Arduino coding kit
  • 4. Arduino coding kit • 1 x arduino • 1 x fork • 1 x power • 1 x button • 2 x dimmer • 1 x bargraph • 1 x servo
  • 5. Arduino It's an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board
  • 6. Node.js & johnny- five • johnny-five is an Open Source, Firmata Protocol based, IoT and Robotics programming framework • “..johnny-five wants to be a baseline control kit for hardware projects, allowing you the freedom to build, grow and experiment with diverse JavaScript libraries of your own choice..”
  • 7. Setting up Arduino board ! • Connect the Arduino module to the computer using USB • Connect power module because the Arduino module is not powered via USB. • Upload StandardFirmata to Arduino board using the Arduino IDE
  • 8. Demo • Using dimmers to draw to the screen just like an Etch-a-sketch.
  • 9. Little bits in action • 1x Arduino • 1x power • 1 x fork • 2 x dimmers • 1 x button
  • 11. Code • Webpage as web interface for our etch- a-sketch (HTML5 canvas + socket.io) • Node webserver that will read the X and Y values from dimmers and communicate to our client (socket.io + johnny-five)
  • 12. Server code board.on("ready", function() { ! joystick = new five.Joystick({ pins: ["A1", "A0"], freq: 100 }); button=new five.Button(0);
  • 13. Server code html = fs.readFileSync('draw.html').toString(); ! server = http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end(html); });
  • 14. Server code io.listen(server).on('connection', function (socket) { // send the X, Y values to the client joystick.on("axismove", function(err, timestamp) { console.log(this.fixed.x, this.fixed.y); socket.emit('drawing', this.fixed); }); ! button.on("press", function(value){ socket.emit('clear'); }); });
  • 15. Client code ! socket.on('clear', function(){ context.clearRect(0,0,600,400); context.beginPath(); }); ! socket.on('drawing', function (data) { $('#status').html('Connected (x: ' + data.x + ', y: ' + data.y + ')'); // scale values to match canvas size data.x *= 600; data.y *= 400; // if values have changed, draw a line to the new position if (prev && (prev.x != data.x || prev.y != data.y)) { context.moveTo(prev.x, prev.y); context.lineTo(data.x, data.y); context.stroke(); } prev = data; });
  • 18. Credits • little-bits-js:Anna Gerber has created several exercise that you could do with little bits, included the etch-a- sketch that you’ve seen (https:// github.com/AnnaGerber/little-bits-js) • Images of bits used in this presentation have been sourced from littlebits.cc and used under a Creative Commons CC-BY-SA license.