SlideShare a Scribd company logo
Do	you	want	to	build	a	
robot?
Anna	Gerber
Robot	Design
A	robot	is	an	autonomous	system	that	senses	
and	responds	to,	or	acts	upon	the	physical	world
Sensors
(Inputs	e.g.	ultrasonic	sensor)
Control
(Microcontroller	or	
Single-Board-Computer)
Actuators
(Outputs	e.g.	motors)
PowerChassis
JS	Robotics
• http://johnny-five.io/
• https://www.espruino.com/
• https://tessel.io/
• https://docs.particle.io/reference/javascript/
• https://cylonjs.com/
• http://jerryscript.net/
• http://mujs.com/
• http://duktape.org/
Selecting	hardware
• Johnny-Five	supports	Arduino,	Raspberry	Pi,	Tessel,	Particle,	
BeagleBone,	and	more
Johnny-Five
• Open	Source	JavaScript	Robotics	
Framework	for	Node.js
https://github.com/rwaldron/johnny-five
• Communicates	with	microcontrollers	like	
Arduino	using	the	Firmata protocol
• Runs	on-board	devices	that	can	run	Node.js
e.g.	Raspberry	Pi,	BeagleBone Black,	via	I/O	
Plugins
Set	up	Raspberry	Pi	Zero	W	(headless)
• Install	Raspbian:
• https://www.raspberrypi.org/documentation/installation/installing-
images/README.md
• Create	a	file	named	wpa_supplicant.conf on	the	microSD	card:
network={
ssid="campjs"
psk="morecoffee"
}
• Add	a	file	named	ssh (contents	don’t	matter)	on	the	root	of	the	
microSD	card	to	enable	SSH	on	boot
Connect	to	the	Raspberry	Pi
• Rpi uses	mDNS so	connect	to	the	Pi	over	SSH:
• ssh pi@raspberrypi.local
• Default	password	is	raspberry
• (Make	sure	you	change	this)
• Raspbian comes	with	node.js installed	but	if	you	are	using	something	
else,	install	node
• Then	use	npm to	install	the	dependencies:
• npm install	serialport
• npm install	johnny-five	raspi-io
Raspberry	Pi	GPIO
• Solder	some	headers	on	to	the	Raspberry	
Pi	Zero	W	for	the	GPIO	pins
• Peripheral	components	(e.g.	sensors,	
actuators)	attach	via	these	pins
• 3.3V	logic
• In	Johnny-Five	the	pins	are	named	
"P[header]-[pin]”	e.g.	P1-7
Breadboard
• Use	to	prototype	circuits	without	soldering	by	
plugging	in	components	and	jumper	wires
• Numbered	rows	are	connected
• Some	have	power	rails	along	the	sides
Attach	an	LED	using	a	Breadboard
Writing	Johnny-Five	programs
1. Create	a	JavaScript	file	(e.g.	blink.js)	on	the	Pi
2. Edit	it	using	a	text	editor	
3. Require	the	johnny-five	library	and	raspi-io libraries	into	and	set	up	the	
board	object	using	the	IO/Plugin
const raspi = require('raspi-io');
const five = require('johnny-five');
const board = new five.Board({
io: new raspi()
});
Ready	event
• When	the	board	is	ready	for	our	code	to	start	interacting	with	it	and	
the	attached	sensors	and	actuators,	it	will	trigger	a	ready	event
board.on('ready', () => {
// code for sensors, actuators goes here
});
LED
• Create	an	Led	instance
// attach LED on pin 7
const led = new five.Led('P1-7');
// call strobe function to blink once per second
led.strobe(1000);
• We	can	change	the	parameter	to	the	strobe	function	to	change	the	speed:	This	
input	value	is	provided	in	milliseconds
LED	blink	program
const raspi = require('raspi-io');
const five = require('johnny-five');
const board = new five.Board({
io: new raspi()
});
board.on('ready', () => {
// LED attached to RPi pin 7 (GPIO4)
const led = new five.Led('P1-7');
led.strobe(500);
});
Inputs	- Sensors
• Environmental	conditions (e.g.	temperature,	humidity)
• Magnetic	(e.g.	hall	effect	sensor)
• Light	(e.g.	photo	resistor)
• Sound	(e.g.	microphone,	piezo)
• Movement	/	position	(e.g.	accelerometer,	tilt	switch)
• User	Input	(e.g.	button)
Inputs
PHOTO	RESISTOR
Resistance changes	depending	on	the	
amount	of ambient light
TILT	SWITCH
Detect	orientation
PUSH	BUTTON
Also known	as	momentary	switch
PIEZO	ELEMENT
Detect	vibrations or	knocks
TEMPERATURE	SENSOR
Read the	ambient	temperature
Outputs
• Light	&	Displays	(e.g.	LED,	LCD	screen)
• Sound	(e.g.	Piezo buzzer)
• Movement	(e.g.	Servo,	DC	Motor,	Solenoid)
• Relays
Outputs
PIEZO	ELEMENT
A	pulse	of	current	will	cause	it	to	click.	A	stream	of	
pulses	will	cause	it	to	emit	a	tone.
RGB	LED
We	are	using	Common	Cathode	RGB	LEDs.	The	
longer	lead	is	the	common	lead	which	connects	to	
ground.	The	three	other	leads	are	for	Red,	Green	
and	Blue	signal
9G	HOBBY	SERVO
A	box containing	a	motor	with	gears	to	make	it	
positionable from	0	to	180	degrees.
Digital	vs Analog
• Digital
• discrete	values	(0	or	1)
• Examples:	tilt	sensor,	push	button
• Analog
• continuous	values
• typically	values	for	analog	sensors	are	constrained	within	a	range	e.g.	0	– 255,	
0	– 1023
• Example:	photo	resistor
• Some	components	support	both	digital	and	analog
REPL
• Read,	Eval,	Print	Loop
• A	console	for	real-time	interaction	with	the	code
• Expose	our	variables	to	the	REPL	to	enable	interactive	control:
board.on('ready', () => {
// LED attached to RPi pin 7 (GPIO4)
const myLed = new five.Led('P1-7');
myLed.strobe(500);
board.repl.inject({
led: myLed
});
});
Controlling	the	LED	via	the	REPL
• At	the	REPL	prompt	type	commands	followed	by	enter
• Try:
• stop,	
• on,	
• off,	
• toggle,	
• strobe
e.g:
>>	led.stop()
Buttons
const button	=	new	five.Button("P1-11");		
const led	=	new	five.Led("P1-7");		
button.on("down",	(value)	=>	{				
led.on();
});
button.on(”up",	(value)	=>	{				
led.off();
});
http://johnny-five.io/api/button/
Servos
const myServo =	new	five.Servo("P1-35");
board.repl.inject({
servo:	myServo
});
myServo.sweep();
board.wait(5000,	()	=>	{
myServo.stop();
myServo.center();
});
PWM
• Pulse	Width	Modulation
• Produce	analog	output	via	digital	pins
• Instead	of	on	or	off,	a	square	wave	is	sent	to	simulate	voltages	
between	0V	(off)	and	5V	(on)
• Used	to	control	motors,	fade	LEDs etc
Piezo
const piezo	=	new	five.Piezo("P1-32");
let val = 0;
board.loop(200,	function()	{
if (val ^= 1) {
//	Play	note	a4	for	1/5	second
piezo.frequency(five.Piezo.Notes["a4"],	200);
}
});
Motors
const leftMotor = new five.Motor({
pins: {pwm: "P1-35", dir: "P1-13"},
invertPWM: true
});
const rightMotor = new five.Motor({
pins: {pwm: "P1-32", dir: "P1-15"},
invertPWM: true
});
leftMotor.forward(150);
rightMotor.forward(150);
See	Johnny-Five	motor	API
http://johnny-five.io/api/motor/
Node-RED
• Anna’s	blog:	http://crufti.com
• http://johnny-five.io/
• Node-ARDX	(examples	for	Arduino):	http://node-ardx.org
Read	more

More Related Content

PPTX
American Fuzzy Lop
PDF
ABYSS OF BADUSB
PDF
Fuzzing underestimated method of finding hidden bugs
PPTX
ODP
ArtLung Rosetta Presentation for NC JQuery & JavaScript Camp
PPT
Nut en noodzaak hacken
PPTX
Linx privx privileges-sudo misconfiguration group and docker daemon privileges
PDF
"Serverless" express
American Fuzzy Lop
ABYSS OF BADUSB
Fuzzing underestimated method of finding hidden bugs
ArtLung Rosetta Presentation for NC JQuery & JavaScript Camp
Nut en noodzaak hacken
Linx privx privileges-sudo misconfiguration group and docker daemon privileges
"Serverless" express

Similar to Do you want to build a robot (20)

PDF
Killer Robots 101 with Gobot
PPTX
Forensics WS Consolidated
PDF
UI Beyond the Browser - Software for Hardware Projects
PPTX
Js robotics
PDF
Day 1 slides UNO summer 2010 robotics workshop
PPTX
Introduction to Bug and Bugzilla
PDF
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
PDF
Hardware for JavaScript Developers
PPT
Microsoft Robotics Studio
PDF
Bot. You said bot? Let build bot then! - Laurent Ellerbach
PPTX
ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...
PDF
오픈소스로 시작하는 인공지능 실습
PDF
Live, Work, Play with Intelligent Robots
PPTX
Debugging Tips and Tricks - iOS Conf Singapore 2015
PDF
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
PPTX
Nodebots
PDF
Internet of Things 101 - For software engineers
PDF
Mozilla chirimen firefox os dwika v5
PDF
Legal and efficient web app testing without permission
PDF
From native code gems to Java treasures with jextract
Killer Robots 101 with Gobot
Forensics WS Consolidated
UI Beyond the Browser - Software for Hardware Projects
Js robotics
Day 1 slides UNO summer 2010 robotics workshop
Introduction to Bug and Bugzilla
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
Hardware for JavaScript Developers
Microsoft Robotics Studio
Bot. You said bot? Let build bot then! - Laurent Ellerbach
ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...
오픈소스로 시작하는 인공지능 실습
Live, Work, Play with Intelligent Robots
Debugging Tips and Tricks - iOS Conf Singapore 2015
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
Nodebots
Internet of Things 101 - For software engineers
Mozilla chirimen firefox os dwika v5
Legal and efficient web app testing without permission
From native code gems to Java treasures with jextract
Ad

More from Anna Gerber (20)

PDF
Internet of Things (IoT) Intro
PPTX
How the Web works
PDF
Iot 101
PPTX
Adding Electronics to 3D Printed Action Heroes
PPTX
3D Printing Action Heroes
PPTX
3D Sculpting Action Heroes
PDF
International NodeBots Day Brisbane roundup (BrisJS)
PDF
JavaScript Robotics
PDF
Intro to Electronics in Python
PDF
Data Visualisation Workshop (GovHack Brisbane 2014)
PPTX
Supporting Open Scholarly Annotation
PPTX
Supporting Web-based Scholarly Annotation
PDF
Annotations Supporting Scholarly Editing (OA European Roll Out)
PDF
Annotation Tools (OA European Roll Out)
PDF
Intro to data visualisation
PPTX
Annotations Supporting Scholarly Editing
PPTX
Getting started with the Trove API
PPT
Intro to Java
PPTX
HackFest Brisbane: Discover Brisbane
PPTX
Using Yahoo Pipes
Internet of Things (IoT) Intro
How the Web works
Iot 101
Adding Electronics to 3D Printed Action Heroes
3D Printing Action Heroes
3D Sculpting Action Heroes
International NodeBots Day Brisbane roundup (BrisJS)
JavaScript Robotics
Intro to Electronics in Python
Data Visualisation Workshop (GovHack Brisbane 2014)
Supporting Open Scholarly Annotation
Supporting Web-based Scholarly Annotation
Annotations Supporting Scholarly Editing (OA European Roll Out)
Annotation Tools (OA European Roll Out)
Intro to data visualisation
Annotations Supporting Scholarly Editing
Getting started with the Trove API
Intro to Java
HackFest Brisbane: Discover Brisbane
Using Yahoo Pipes
Ad

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Empathic Computing: Creating Shared Understanding
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Assigned Numbers - 2025 - Bluetooth® Document
The Rise and Fall of 3GPP – Time for a Sabbatical?
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Spectral efficient network and resource selection model in 5G networks
MIND Revenue Release Quarter 2 2025 Press Release
Review of recent advances in non-invasive hemoglobin estimation
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
Empathic Computing: Creating Shared Understanding
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Assigned Numbers - 2025 - Bluetooth® Document

Do you want to build a robot