Julio César Rodríguez
(@_Jurasec)
“any application that can be written in JavaScript, will eventually be written in JavaScript.”
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain. http://arduino.cc/en/tutorial/blink
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
pinMode(led, OUTPUT); // initialize the digital pin as an output.
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a sec
var five = require("johnny-five"),
board = new five.Board();
board.on("ready", function() {
(new five.Led(13)).strobe(); // Create an Led on pin 13 and strobe it on/off
});
$( document ).ready(function() {
console.log( "ready!" );
});
var five = require("johnny-five"),
board = new five.Board();
board.on("ready", function() {
console.log( "ready!" );
});
var five = require("johnny-five"),
board = new five.Board(),
laserDiode;
board.on("ready", function() {
laserDiode = new five.Led({
pin: 9
});
// Hacemos que este disponible el objeto "laserDiodo" dentro del REPL
this.repl.inject({
laser: laserDiode
});
laser.on()
// Dentro del REPL, puedes probar el PWM con: laser.pulse()
});
var five = require("johnny-five"), board = new five.Board(),
photoresistor;
board.on("ready", function() { // Creamos una instancia de Sensor, indicándole que lea con una frecuencia de 100 milisegundos. photoresistor = new five.Sensor({ pin: "A2", freq: 100 }); photoresistor.on("data", function() { console.log(this.value); }); });
var five = require("johnny-five"),
board = new five.Board(),
laserDiode;
board.on("ready", function() {
laserDiode = new five.Led({
pin: 9
});
// Hacemos que este disponible el objeto "laserDiode" dentro del REPL
this.repl.inject({
laser: laserDiode
});
// Creamos una instancia de Sensor, indicándole que lea con una frecuencia de 100 milisegundos.
photoresistor = new five.Sensor({
pin: "A2",
freq: 100
});
laserDiode.on()
photoresistor.on("data", function() {
console.log(this.value);
if( this.value > 100){
console.log('_________uu$$$$$$$$$$$$$$$$$uu__________');
console.log('_________u$$$$$$$$$$$$$$$$$$$$$u_________');
console.log('________u$$$$$$$$$$$$$$$$$$$$$$$u________');
console.log('_______u$$$$$$$$$$$$$$$$$$$$$$$$$u_______');
console.log('_______u$$$$$$$$$$$$$$$$$$$$$$$$$u_______');
console.log('_______u$$$$$$”___”$$$”___”$$$$$$u________');
console.log('_______”$$$$”______u$u_______$$$$”________');
console.log('________$$$———u$u_______u$$$________');
console.log('________$$$u______u$$$u______u$$$________');
console.log('_________”$$$$uu$$$___$$$uu$$$$”_________');
console.log('__________”$$$$$$$”___”$$$$$$$”__________');
console.log('____________u$$$$$$$u$$$$$$$u____________');
console.log('_____________u$”$”$”$”$”$”$u______________');
console.log('__uuu________$$u$_$_$_$_$u$$_______uuu__');
console.log('_u$$$$________$$$$$u$u$u$$$_______u$$$$_');
console.log('__$$$$$uu______”$$$$$$$$$”_____uu$$$$$$__');
console.log('u$$$$$$$$$$$uu____”””””____uuuu$$$$$$$$$$');
console.log('$$$$”””$$$$$$$$$$uuu___uu$$$$$$$$$”””$$$”');
console.log('_”””______””$$$$$$$$$$$uu_””$”””___________');
console.log('___________uuuu_””$$$$$$$$$$uuu___________');
console.log('__u$$$uuu$$$$$$$$$uu_””$$$$$$$$$$$uuu$$$__');
console.log('__$$$$$$$$$$””””___________””$$$$$$$$$$$”__');
console.log('___”$$$$$”______________________””$$$$””__');
}
});
console.log( 'LD ready!' );
});
npm install johnny-five
https://github.com/rwaldron/johnny-five
http://www.geekytime.net/arduino/como-iniciar-con-arduino-y-johnny-five/