Welcome

International Nodebots Day

Houston, 2017

nodebots.io

Alan Lee

Donovan Buck

Michelle Wigington

Pierce Primm

Ryan Gill

Sponsors

MRI Dev Team

2016

Agenda

johnny-five.io

Important Points
To Consider

The only dumb question is the one you never asked.

Doesn't work?
It's probably the hardware.

Overview

  • Tessel 2
  • T2 CLI
  • Tessel Experiments
  • Build a NodeBot

Tessel 2

Hardware Specs

CPU MIPS 24KEc 580MHz
RAM 64MB
Flash 32MB
WiFi b/g/n 2.4GHz
Ethernet 10/100Mbps
USB 2 x USB 2.0
MCU ARM Cortex M0 48MHz

The Tessel Mission

Create a fully open source hardware & software platform that makes it easy and intuitive to develop Internet-connected devices.

Core Philosophies

  • Developer experience is paramount
  • Device design should focus on user experience rather than on implementation
  • Openness promotes innovation
  • Tessel should be practical to use
  • Community matters

Follow Along

https://nodejshouston.github.io/nbd2017/

Let's learn about your

NBD Houston

Starter Kit!

Tessel 2

Breadboard: Solderless wiring

Breadboard: Electrical Connections

Resistors: Reduce Current Flow, lower Voltage Level

LEDs: Light Up Your Life

Buttons, Potentiometer

Jumper Wires!

Pro tips!

  • Start charging your USB battery
  • Be mindful of your 9-volt(s). You'll want a fresh battery come race time

Getting started with the Tessel

Tessel Logo

Open Terminal (Mac)

Applications --> Utilities --> Terminal
Tessel Logo

Terminal

Tessel Logo

Open Command Prompt (Windows)

Click start --> type `command prompt` --> hit enter
Utilities

Check your node.js version

node -v

6.11.1 is the latest, but any LTS Version should work

Argon - 4.2.0 - 4.8.4
Boron - 6.9.0 - 6.11.1

Install Tessel CLI

npm install -g t2-cli

Note: If you get the common npm EACCES error, correct it by fixing npm permissions and run the command again.

https://docs.npmjs.com/getting-started/fixing-npm-permissions

Connect The Tessel to your computer via USB

Find your Tessel

t2 list

Name your Tessel

t2 rename mario

Authorize

t2 provision

Create working directory

mkdir t2_fun && cd t2_fun

Initialize project

t2 init

Run a file

t2 run index.js
t2 run name_of_file

Copy the file and its dependencies into Tessel's RAM & run immediately. Use this during development of your device application.

Flag Description
--lan deploy over LAN connection
--usb deploy over USB connection
--slim copy only files needed by the program to run
--full copy all the files in the project directory

Push a file

t2 push index.js
t2 push name_of_file

Copy the file and its dependencies into Tessel's Flash memory & run immediately. Once deployed with push command, the device application will automatically run every time the Tessel restarts.

Flag Description
--lan deploy over LAN connection
--usb deploy over USB connection
--slim copy only files needed by the program to run
--full copy all the files in the project directory

Erase Files

t2 erase
t2 erase

Erase any code previously pushed to the Tessel using the t2 push command.

Using Wifi

t2 wifi
t2 wifi -n SSID -p PASSWORD
Flag Description
-l list available networks
-n network SSID
-p password for wifi
-s security type (wep, psk, psk2 wpa, wpa2)
--off disconnect from wifi
--on connect to last configured network

NOTE: try turning off access point before connecting to wifi.

t2 ap --off

Create An Access Point

t2 ap -n NAME -p PASSWORD
t2 ap -n SSID -p PASSWORD
Flag Description
-n name of network to create
-p optional password for network
-s optional security type (wep, psk, psk2 wpa, wpa2)
--off turn off current access point
--on turn on most recent access point

NOTE: try turning off wifi before creating access point.

t2 wifi --off

Ready To Make Stuff?

Create Output

npm install johnny-five tessel-io

Make a new file

Mac users:

touch led-on.js

Windows users:

type nul > led-on.js

Connect positive lead (long) to pin A0 and the negative lead (short) to ground.

Turn LED on

var five = require("johnny-five");
var Tessel = require("tessel-io");
var board = new five.Board({
  io: new Tessel()
});

board.on("ready", function() {
  var led = new five.Led("A0");
  led.on();
});
t2 run led-on.js

http://johnny-five.io/api/board
http://johnny-five.io/api/led

Make LED blink

var five = require("johnny-five");
var Tessel = require("tessel-io");
var board = new five.Board({
  io: new Tessel()
});

board.on("ready", function() {
  var led = new five.Led("A0");
  led.blink();
});
t2 run led-blink.js

Change the blink rate.

var five = require("johnny-five");
var Tessel = require("tessel-io");
var board = new five.Board({
  io: new Tessel()
});

board.on("ready", function() {
  var led = new five.Led("A0");
  led.blink(2500); // <-- ms on/off phases
});
t2 run led-blink-slow.js

Create Digital Input

0|1



Respond to Button Press

var five = require("johnny-five");
var Tessel = require("tessel-io");
var board = new five.Board({
  io: new Tessel()
});

board.on("ready", function() {
  var button = new five.Button("A2");

  button.on("press", function() { console.log("Button Pressed!")});
  button.on("release", function() { console.log("Button Released!")});
});
t2 run button.js

http://johnny-five.io/api/button

Let's try Push

Instead of the run command, we will use the push command which copies the file on to the tessel and will now run this file at boot on every startup.

Convert Input to Output

var five = require("johnny-five");
var Tessel = require("tessel-io");
var board = new five.Board({
  io: new Tessel()
});

board.on("ready", function() {
  var led = new five.Led("A5");
  var button = new five.Button("A2");

  button.on("press", function() { led.on() });
  button.on("release", function() { led.off() });
});
t2 push button-led.js

Multiple States of Input to Multiple States of Output

var five = require("johnny-five");
var Tessel = require("tessel-io");
var board = new five.Board({
  io: new Tessel()
});

board.on("ready", function() {
  var led = new five.Led("A5");
  var button = new five.Button("A2");

  button.on("press", function() { led.on() });
  button.on("hold", function() { led.blink(50) });
  button.on("release", function() { led.stop().off() });
});
t2 push button-states.js

Observe Analog Input

Tessel 2 analog in pins:

  • A4, A7
  • B0 - B7

Variable Input

Receive Values From a Sensor

var five = require("johnny-five");
var Tessel = require("tessel-io");
var board = new five.Board({
  io: new Tessel()
});

board.on("ready", function() {
  var rotary = new five.Sensor("A7");

  rotary.on("change", function() {
    console.log("Sensor changed!", this.value);
  });
});
t2 run sensor.js

http://johnny-five.io/api/sensor

PWM

Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means.
Digital control is used to create a square wave, a signal switched between on and off.
- Arduino.cc

Control the brightness

var five = require("johnny-five");
var Tessel = require("tessel-io");
var board = new five.Board({
  io: new Tessel()
});

board.on("ready", function() {
  var sensor = new five.Sensor({
    pin: "a7",
    threshold: 2
  });
  var led = new five.Led("b5");

  sensor.on("change", () => {
    led.brightness(sensor.scaleTo(0, 255));
  });
});
t2 run brightness.js

Let's get untethered

t2 push brightness.js

Unplug the Tessel from your computer and plug it into the USB battery. Wait for the lights on the Ethernet port.

Let's Build A Robot

Peewee Bot Build Video

Break

Wiring

High Level Hardware

High Level App

In Case of Emergency!

johnny-five.io

Let's get ready to race!!!

Additional Resources