12. <!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>
13.
14.
15.
16.
17. NodeJS pros:
● Fast, very fast
● Asynchronous
● Event-based
● Top 1 language in the world
18.
19.
20.
21.
22. 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.
+
23.
24.
25. Firmata
Firmata 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.
26.
27.
28.
29. 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);
}
30. Single boards
Raspberry 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
31. Single boards
Intel 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
32. Single boards
Tessel 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
36. 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
37. 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!