Physical Computing: 2

Physical Computing: 2

Physical Computing: 2

Physical Computing: 2

<<<<<<< HEAD

Slides are here:
http://mhellar.github.io/physcomp2/3


Grab the code here:
http://bit.ly/2zP5PId

    Topics for Today:

  • Johnny-Five..
  • Fritzing
  • Twitter Lamp
  • Twitter Button
  • Introduction to the ESP8266
  • Project Planning Break out
=======

Slides are here:
http://mhellar.github.io/physcomp2/1


Grab the code here:
https://bit.ly/2J4OTRD

    Topics for This Week:

  • The Johnny Five Library
  • Creating a Twitter Lamp
  • Create and Twitter Button
  • API to LCD
  • Fritzing
>>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc

Johnny-Five is the original JavaScript Robotics programming framework. Released by Bocoup in 2012, Johnny-Five is maintained by a community of passionate software developers and hardware engineers. Over 75 developers have made contributions towards building a robust, extensible and composable ecosystem.

<<<<<<< HEAD
=======
>>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc

Starting a new Node app

  • Create a new folder named, 'J5_led_1'
  • Open the terminal
  • type 'cd' & space
  • drag your folder to the terminal and hit return
  • Now we are in our new folder in the terminal
  • Type 'npm init' & hit return
  • fill out the questions
  • drag your folder onto Sublime Text
  • type 'npm install johnny-five --save
  • Have a look at the package.json file that was generated
  • This stores metadata about our app

contents of package.json


<<<<<<< HEAD
                {
                  "name": "J5_led_1",
                  "version": "1.0.0",
                  "description": "A Johnny Five LED app",
                  "main": "index.js",
                  "scripts": {
                    "test": "echo \"Error: no test specified\" && exit 1"
                  },
                  "author": "",
                  "license": "ISC",
                  "dependencies": {
                    "johnny-five": "^0.8.106"
                  }
                }
                
======= { "name": "J5_led_1", "version": "1.0.0", "description": "A Johnny Five LED app", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "johnny-five": "^0.8.106" } } >>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc

create a new file, enter the following code and save as index.js in your new folder

<<<<<<< HEAD
                var five = require("johnny-five");
                var board = new five.Board();
                
                board.on("ready", function() {
                  var led = new five.Led(6);
                  led.blink(500);
                });
                
  • Upload firmata to arduino
  • ======= var five = require("johnny-five"); var board = new five.Board(); board.on("ready", function() { var led = new five.Led(6); led.blink(500); });
  • !!! Upload firmata to arduino !!!
  • >>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc
  • run 'node index.js' at the terminal

try a pulse

<<<<<<< HEAD
                var five = require("johnny-five");
                var board = new five.Board();
                
                board.on("ready", function() {
                  var led = new five.Led(6);
                led.pulse(500);
                });
                
======= var five = require("johnny-five"); var board = new five.Board(); board.on("ready", function() { var led = new five.Led(6); led.pulse(500); }); >>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc

Led Animations


<<<<<<< HEAD
                var five = require("johnny-five");
                var board = new five.Board();
                
                board.on("ready", function() {
                  var led = new five.Led(6);
                led.pulse({
                  easing: "linear",
                  duration: 3000,
                  cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1],
                  keyFrames: [0, 10, 0, 50, 0, 255],
                  onstop: function() {
                    console.log("Animation stopped");
                  }
                });
                });
                
======= var five = require("johnny-five"); var board = new five.Board(); board.on("ready", function() { var led = new five.Led(6); led.pulse({ easing: "linear", duration: 3000, cuePoints: [0, 0.2, 0.4, 0.6, 0.8, 1], keyFrames: [0, 10, 0, 50, 0, 255], onstop: function() { console.log("Animation stopped"); } }); }); >>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc

Reference


LED API
Animation API
Full API
<<<<<<< HEAD

Project 1

Connect a servo

From the terminal:


'cd j5SocketInputServo'


'node app.js'

Fritzing.org

Project: Twitter Lamp

Make this circuit

Go Here:


https://apps.twitter.com/

create a new app

Gather tokens and keys



Update code in code/twitter-ard/app.js


=======
                

Project: Twitter Lamp

Make this circuit

Go Here:


https://apps.twitter.com/

create a new app

Gather tokens and keys



Update code in code/twitter-ard/app.js


>>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc
var client = new Twitter({
    consumer_key: 'Enter Here',
    consumer_secret: 'Enter Here',
    access_token_key: 'Enter Here',
    access_token_secret: 'Enter Here'
})
<<<<<<< HEAD

From the terminal:


'cd twitter-ard'


'node app.js'

From the terminal:


'cd twitter-ard-location'


'node app.js'

Twitter API Reference


Here

Project: Twitter Button

Update code in code/twitter-ard/app.js


=======
                

From the terminal:


'cd twitter-ard'


'node app.js'

From the terminal:


'cd twitter-ard-location'


'node app.js'

Twitter API Reference


Here

Project: Twitter Button

Update code in code/twitter-ard/app.js


>>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc
var client = new Twitter({
    consumer_key: 'Enter Here',
    consumer_secret: 'Enter Here',
    access_token_key: 'Enter Here',
    access_token_secret: 'Enter Here'
})
<<<<<<< HEAD

From the terminal:


'cd twitter-button'


'node app.js'

The ESP8266

We need to solder the header pins on, let's do that now

The ESP8266 is a low-cost Wi-Fi chip with full TCP/IP stack and MCU (Micro Controller Unit) capability produced by Shanghai-based Chinese manufacturer, Espressif Systems.

The Adafruit Feather is a mini Arduino with Wifi, that is $16.00!


ESP8266 core for Arduino

Getting Set up:
- First install the USB driver SiLabs serial driver

Getting Set up:
- Next go to the Arduino Preferences

Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Boards Manager URLs

Getting Set up:
- Next, use the Board manager to install the ESP8266 package.

Getting Set up:
Set Board to Adafruit HUZZAH ESP8266
Set port to SLABusbtoUART

Connect an led


Upload Blink


Upload WiFiWebServer


Upload ESPwebpage


Hook Up A Servo


Upload ESPwebpageServo


=======

From the terminal:


'cd twitter-button'


'node app.js'

Let's hook up the Liquid Crystal Display


Detailed Reference

Upload Firmata to Arduino

code7/j5_lcd_weather


node app.js

code7/j5_lcd_bart


node app.js

node-pixel

Connect GND, 5V, DI to pin 3

Node-pixel only works with Node LTS version


sudo n lts

Node-pixel needs a special version for Firmata


git clone https://github.com/ajfisher/node-pixel

Upload node_pixel_firmata.ino from the repo you just cloned

  • cd j5pixel from the code folder
  • npm install
  • node app.js
  • also try rainbow.js
  • cd PhysicalNeopixel from the code folder
  • npm install
  • node panel.js
  • open localhost:3000

Reference


node-pixel
>>>>>>> 6a7bd66c79ee9ea4ba1a9bedf93f95b5c411cbfc