Becoming a maker: Microcontrollers
AND JAVASCRIPT USING JOHNNY-FIVE
Who am I?
http://bit.ly/ becoming-a-maker
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/2861619/profile.jpg)
We are all makers
- Makers are enthusiasts, amateurs, DIY'ers, recyclers, reuse'ers, and crafters.
- Makers always asking themselves "Can I do it? Can it be done?"
- The talk is label "Becoming a maker" but really we are all makers.
?
- Who here considers themselves a maker?
- Do you know JavaScript and not C?
- Own/tinkered with Arduino/Raspberry Pi or other microcontroller boards?
The Sandlot
The Sandlot
Sashimi Tabernacle Choir
Mk. II MegaBot
five finger fillet Machine
My Maker Background
- High school class making Lego robots
- Building Computers
- Took a soldering class
- Made a few custom PC cases
- Wood working
- Tinkering with Arduinos and JS
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/2863755/co-flag.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/2863756/workshop.jpg)
What will be covered?
- What's a microcontroller?
- What hardware basics should you learn?
- What's Johnny-Five.js?
- Setting Johnny Five up with Arduino
- Arduino Demos
- Setting Johnny-Five up with Tessel 2
- Tessel 2 Demos
What's A microcontroller?
A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals.
arduino vs Tessel 2
Arduino
- Open-sourced
- Has an IDE
- Simplified version of C++
- Can run Node.js/Johnny-five after installing the Firmata protocol
- CAN'T run a Node.js app without a computer
- Perfect for rapid prototyping on the cheap
Tessel 2
- Open-sourced
- Linux
- Runs Node.js out of the box
- CAN run Node.js applications without a computer
- Pre-made/configured modules/shields
- Perfect for rapid prototyping and production ready
Shopping list
Arduino
- Theres about 22+ flavors
- Recommend starting boards
- Arduino Uno
- Sparkfun Red Board(Simplified Uno)
- Recommended Starter Kits
- SparkFun Inventor's Kit - comes with RedBoard
Tessel 2
- 1 flavor
- Recommend starting boards
- Recommended Starter Kits
- Johnny-Five Inventor's Kit - comes with Tessel 2
What Hardware Basics Should I learn?
What Hardware Basics Should I learn?
- Electronics Primer - learn basic hardware components and their purpose like resistors, motors, relay, etc...
- How to use a breadboard - best friend for prototyping without soldering
- Soldering(is fun) and De-soldering(sucks, takes practice)
- Multimeter - nifty tool for debugging
Hello, Johnny-five!
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/2889243/j5-wave.gif)
What is Johnny-Five?
- Open source JS robotics programming framework
- Created by Rick Waldron in 2012
- Maintained by a community of passionate software developers and hardware engineers
- Community is super duper nice and noob friendly
Why Johnny-Five?
- You don't have to learn C
- No Compiling - just run `node blahfile.js` in terminal and/or REPL for debugging/experimenting
- Most popular JS robotics framework
- Atwood’s Law - any application that can be written in JavaScript will eventually be written in JavaScript.
- Ummm cause why not?
Johnny-Five community = Awesomesauce
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/1616233/nintendo-ds-screen-help.jpg)
Setting Up Arduino & J5 - Part 1
- Download Arduino IDE
- Connect your Arduino-compatible microcontroller via USB
- Launch Arduino IDE and open the Firmata sketch via the menu: File > Examples > Firmata > StandardFirmata
- Select your Arduino board type (e.g. Arduino Uno) via Tools > Board
- Select the port for your board via Tools > Serial Port > (the comm port of your Arduino)
- Upload the program by selecting File > Upload
- Close the Arduino IDE and then...
Setting Up Arduino & J5 - Part 1.5
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/2888679/killitwithfire.gif)
- Install Node JS
- Make a new project folder
-
npm init (follow prompts)
-
npm install --save johnny-five
Setting Up Arduino & J5 - Part 2
Arduino + J5 = DEMOs!!!!
Hello World - Blinking led - Code
var five = require('johnny-five');
var board = new five.Board();
board.on('ready', function() {
var led = new five.Led(11);
// This will grant access to the led instance
// from within the REPL that's created when
// running this program.
this.repl.inject({
led: led
});
led.blink();
});
Hello World - BLINKING LED - layout
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/1617445/led-11-pwm.png)
Hello World - BLINKING LED - In Action
Button - Code
var five = require('johnny-five');
var board = new five.Board();
var button;
var led;
board.on('ready', function() {
led = new five.Led(11);
// Create a new `button` hardware instance.
// This example allows the button module to
// create a completely default instance
button = new five.Button(2);
// Inject the `button` hardware into
// the Repl instance's context;
// allows direct command line access
board.repl.inject({
button: button,
led: led
});
// Button Event API
// "down" the button is pressed
button.on('down', function() {
console.log('down');
led.brightness(255);
});
button.on('hold', function() {
console.log('hold');
led.blink(500);
});
// "up" the button is released
button.on('up', function() {
console.log('up');
led.stop(); // Stops the blinking
led.brightness(0);
});
});
Button - Layout
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/1620183/button.png)
Button - In Action
JOYSTICK PAN-TILT - Code
var five = require('johnny-five');
var board = new five.Board();
board.on('ready', function() {
var range = [
0,
180
];
// Servo to control panning
var pan = new five.Servo({
pin: 9,
range: range
});
// Servo to control tilt
var tilt = new five.Servo({
pin: 10,
range: range
});
// Joystick to control pan/tilt
// Read Analog 0, 1
// Limit events to every 100ms
var joystick = new five.Joystick({
pins: [
'A0',
'A1'
],
freq: 100
});
tilt.center();
pan.center();
joystick.on('change', function() {
console.log('y: ', this.y);
console.log('x: ', this.x);
tilt.to(five.Fn.scale(this.y, -1, 1, 0, 170));
pan.to(five.Fn.scale(this.x, -1, 1, 0, 170));
});
});
JOYSTICK PAN-TILT - Layout
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/2890295/joystick-pantilt.png)
JoyStick Pan-tilt - In Action
- Install Node JS
-
npm install -g t2-cli
- Make a new project folder
-
t2 init (in project folder)
-
npm install --save johnny-five tessel-io
Setting Up Tessel 2 & J5
Tessel 2 + J5 = DEMOs!!!!
Need ideas? Here is
- House Automation
- Nerf Turret
- NodeBot
- Home Arcade
- Home Brewing
- Halloween Costumes
- Art Installations
- 3d Printers
- Just Use Your....
Build It and The ideas Will Come
PSsT, Who's Your Dealer?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/57475/images/2888734/deep-web.gif)
Who to buy from?
- SparkFun - Good prices, close by just past Boulder
- Adafruit - great products and prices
- MicroCenter - convenient but more expensive
- RadioShack - believe it or not they still have stuff even bot kits
Questions?
Becoming a maker: Microcontrollers & JavaScript using Johnny-Five
By Matt Webb
Becoming a maker: Microcontrollers & JavaScript using Johnny-Five
- 1,567