SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie Do you want to build a robot

Forensics WS Consolidated
Forensics WS ConsolidatedForensics WS Consolidated
Forensics WS Consolidated
Karter Rohrer
 
Microsoft Robotics Studio
Microsoft Robotics StudioMicrosoft Robotics Studio
Microsoft Robotics Studio
guest76aa93
 
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
[ENG] Hacker halted 2012 - Zombie browsers, spiced with rootkit extensions
Zoltan Balazs
 

Ähnlich wie Do you want to build a robot (20)

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

Mehr von Anna Gerber

Data Visualisation Workshop (GovHack Brisbane 2014)
Data Visualisation Workshop (GovHack Brisbane 2014)Data Visualisation Workshop (GovHack Brisbane 2014)
Data Visualisation Workshop (GovHack Brisbane 2014)
Anna Gerber
 

Mehr von Anna Gerber (20)

Internet of Things (IoT) Intro
Internet of Things (IoT) IntroInternet of Things (IoT) Intro
Internet of Things (IoT) Intro
 
How the Web works
How the Web worksHow the Web works
How the Web works
 
Iot 101
Iot 101Iot 101
Iot 101
 
Adding Electronics to 3D Printed Action Heroes
Adding Electronics to 3D Printed Action HeroesAdding Electronics to 3D Printed Action Heroes
Adding Electronics to 3D Printed Action Heroes
 
3D Printing Action Heroes
3D Printing Action Heroes3D Printing Action Heroes
3D Printing Action Heroes
 
3D Sculpting Action Heroes
3D Sculpting Action Heroes3D Sculpting Action Heroes
3D Sculpting Action Heroes
 
International NodeBots Day Brisbane roundup (BrisJS)
International NodeBots Day Brisbane roundup (BrisJS)International NodeBots Day Brisbane roundup (BrisJS)
International NodeBots Day Brisbane roundup (BrisJS)
 
JavaScript Robotics
JavaScript RoboticsJavaScript Robotics
JavaScript Robotics
 
Intro to Electronics in Python
Intro to Electronics in PythonIntro to Electronics in Python
Intro to Electronics in Python
 
Data Visualisation Workshop (GovHack Brisbane 2014)
Data Visualisation Workshop (GovHack Brisbane 2014)Data Visualisation Workshop (GovHack Brisbane 2014)
Data Visualisation Workshop (GovHack Brisbane 2014)
 
Supporting Open Scholarly Annotation
Supporting Open Scholarly AnnotationSupporting Open Scholarly Annotation
Supporting Open Scholarly Annotation
 
Supporting Web-based Scholarly Annotation
Supporting Web-based Scholarly AnnotationSupporting Web-based Scholarly Annotation
Supporting Web-based Scholarly Annotation
 
Annotations Supporting Scholarly Editing (OA European Roll Out)
Annotations Supporting Scholarly Editing (OA European Roll Out)Annotations Supporting Scholarly Editing (OA European Roll Out)
Annotations Supporting Scholarly Editing (OA European Roll Out)
 
Annotation Tools (OA European Roll Out)
Annotation Tools (OA European Roll Out)Annotation Tools (OA European Roll Out)
Annotation Tools (OA European Roll Out)
 
Intro to data visualisation
Intro to data visualisationIntro to data visualisation
Intro to data visualisation
 
Annotations Supporting Scholarly Editing
Annotations Supporting Scholarly EditingAnnotations Supporting Scholarly Editing
Annotations Supporting Scholarly Editing
 
Getting started with the Trove API
Getting started with the Trove APIGetting started with the Trove API
Getting started with the Trove API
 
Intro to Java
Intro to JavaIntro to Java
Intro to Java
 
HackFest Brisbane: Discover Brisbane
HackFest Brisbane: Discover BrisbaneHackFest Brisbane: Discover Brisbane
HackFest Brisbane: Discover Brisbane
 
Using Yahoo Pipes
Using Yahoo PipesUsing Yahoo Pipes
Using Yahoo Pipes
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Do you want to build a robot