"Any sufficiently advanced technology is indistinguishable from magic."
Javascript ♥ Microcontrollers
<a href="http://home.netscape.com/comprod/mirror/index.html">
<img onmouseover="this.src='on.gif'" onmouseout="this.src='off.gif'">
Best viewed with Netscape Navigator 3.0
</a>
setWatch(function() {
console.log('Yay!');
}, BTN1, { repeat:true, edge:"rising" });
"Any application that can be written in JavaScript will eventually be written in JavaScript."
http = require('http');
LED1.write(1);
wlan = require("CC3000").connect();
wlan.connect("SSID", "omg_his_password_is_cleartext!",
function() { // yay! });
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello, out there! Is the movie over?!');
res.end();
}).listen(80);
var GO = { BACK: 0b0101, FORWARD: 0b1010, LEFT: 0b0110, RIGHT: 0b1001 };
function move(motorState, time) {
if (!running) return;
digitalWrite(outputs, motorState);
setTimeout(stop, time);
}
function stop() {
digitalWrite(outputs, 0);
}
hcsr04 = require("HC-SR04");
sensor = hcsr04.connect(A0, A1, function(distance) {
console.log('Distance is: ' + distance);
});
setInterval(sensor.trigger, 350);
function backup() { inManouver = true; digitalWrite(outputs, GO.BACK); setTimeout(function() { digitalWrite(outputs, GO.RIGHT); setTimeout(function() { inManouver = false; stop(); }, 500); }, 1000); }
sensor = hcsr04.connect(A0, A1, function(distance) { if (running && !inManouver && distance < 20) { backup(); } }); setInterval(sensor.trigger, 350);