From front-end to the hardware

40
From front-end to the hardware Henri Cavalcante

Transcript of From front-end to the hardware

Page 1: From front-end to the hardware

From front-end to the hardware

Henri Cavalcante

Page 2: From front-end to the hardware

+From front-end to the hardware

Page 3: From front-end to the hardware
Page 4: From front-end to the hardware
Page 5: From front-end to the hardware

Henri Cavalcante@henricavalcante

(ESP8266 Firebase ready givaway #fif2016)

Page 6: From front-end to the hardware

How many of you?

Page 7: From front-end to the hardware

May, 1995

Page 8: From front-end to the hardware
Page 9: From front-end to the hardware
Page 10: From front-end to the hardware

May, 1995

Page 11: From front-end to the hardware
Page 12: From front-end to the hardware

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <title>Simple JavaScript Example</title> <script type="text/javascript"> <!-- Hide the script from old browsers function containsblank(s) { for(var i = 0; i < s.value.length; i++) { var c = s.value.charAt(i); if ((c == ' ') || (c == '\n') || (c == '\t')) { alert('The field must not contain whitespace'); return false; } } return true; } // end hiding --> </script></head> <body> <h2>Username Form</h2> <form onSubmit="return(containsblanks(this.userName));" method="post" action="test.php"> <input type="text" name="userName" size=10> <input type="submit" value="SUBMIT"> </form> </body></html>

Page 13: From front-end to the hardware
Page 14: From front-end to the hardware
Page 15: From front-end to the hardware
Page 16: From front-end to the hardware
Page 17: From front-end to the hardware

NodeJS pros:

● Fast, very fast

● Asynchronous

● Event-based

● Top 1 language in the world

● Large community

Page 18: From front-end to the hardware
Page 19: From front-end to the hardware
Page 20: From front-end to the hardware
Page 21: From front-end to the hardware
Page 22: From front-end to the hardware

Johnny-Five

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.

+

Page 23: From front-end to the hardware
Page 24: From front-end to the hardware
Page 25: From front-end to the hardware

FirmataFirmata is a protocol for communicating with microcontrollers from software on a computer (or smartphone/tablet, etc). The protocol can be implemented in firmware on any microcontroller architecture as well as software on any computer software package (see list of client libraries below).

Flash your Arduino with Standard Firmata:

Connect the Arduino to your PC using the USB Cable

Open the Arduino IDE, select: File > Examples > Firmata >

StandardFirmata

Click the "Upload" button.

The text "Done Uploading" will appear once the upload is complete.

Page 26: From front-end to the hardware
Page 27: From front-end to the hardware
Page 28: From front-end to the hardware
Page 29: From front-end to the hardware

Example

const five = require('johnny-five');const board = new five.Board();

board.on('ready', () => { (new five.Led(13)).blink(500);});

void setup() { pinMode(13, OUTPUT);}

void loop() { digitalWrite(13, HIGH); delay(500); digitalWrite(13, LOW); delay(500);}

Page 30: From front-end to the hardware

Single boardsRaspberry Pi 3

Analog Read no

Digital Read yes

Digital Write yes

PWM yes

Servo yes

I2C yes

One Wire no

Stepper no

Serial/UART no

DAC no

Ping no

Page 31: From front-end to the hardware

Single boardsIntel Galileo

Analog Read yes

Digital Read yes

Digital Write yes

PWM yes

Servo yes

I2C yes

One Wire no

Stepper no

Serial/UART no

DAC no

Ping no

Page 32: From front-end to the hardware

Single boardsTessel 2

Analog Read yes

Digital Read yes

Digital Write yes

PWM no

Servo yes

I2C yes

One Wire no

Stepper no

Serial/UART no

DAC yes

Ping no

Page 33: From front-end to the hardware
Page 34: From front-end to the hardware

ESP8266 Usage

ESP 8266

Socket

Sensors

Leds

. . .

Page 35: From front-end to the hardware

Basic Usage

MCU

Serial

Socket

Sensors

Leds

. . .

Page 36: From front-end to the hardware

const five = require('johnny-five');const board = new five.Board();const Firebase = require('firebase');const relays = new Firebase('https://io16natal.firebaseio.com').child('relay');

board.on('ready', () => { const lamps = { '01': new five.Relay(8), '02': new five.Relay(9), '03': new five.Relay(10), '04': new five.Relay(11) } relays.on('value', (snap) => { snap.forEach((lamp) => { lamps[lamp.key()][lamp.val()]() }); });});

Example

Page 37: From front-end to the hardware

http://nodebots.io/

NodeBots are (quite literally) robots of one kind or another that can be controlled via Node. They can have everything from wheels, movable arms and legs, motion detectors, cameras, LED displays, the ability to control cats and so much more. The only limits are your imagination and the components you can find and put together!

Page 38: From front-end to the hardware
Page 39: From front-end to the hardware
Page 40: From front-end to the hardware

github.com/henricavalcante

twitter.com/henricavalcante

fb.me/henricavalcante