From front-end to the hardware
-
Upload
henri-cavalcante -
Category
Documents
-
view
32 -
download
3
Transcript of From front-end to the hardware
From front-end to the hardware
Henri Cavalcante
+From front-end to the hardware
Henri Cavalcante@henricavalcante
(ESP8266 Firebase ready givaway #fif2016)
How many of you?
May, 1995
May, 1995
<!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>
NodeJS pros:
● Fast, very fast
● Asynchronous
● Event-based
● Top 1 language in the world
● Large community
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.
+
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.
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);}
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
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
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
ESP8266 Usage
ESP 8266
Socket
Sensors
Leds
. . .
Basic Usage
MCU
Serial
Socket
Sensors
Leds
. . .
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
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!
github.com/henricavalcante
twitter.com/henricavalcante
fb.me/henricavalcante