ping.on("change", function() {
    console.log("Object is " + this.cm + " cm away");
    if (this.cm <= previousDistance || this.cm <= minDistance){
	previousDistance =  this.cm;

    	board.wait(500, function() {
		console.log("Looking for space");
		visaBot.turnLeft();
	    	board.wait(20, function() {
			console.log("stopping");
			visaBot.stop();
		});

	});
    }
    else {
    	board.wait(1000, function() {
		console.log("moving forward");
		visaBot.forward();
	    	board.wait(20, function() {
			console.log("stopping");
			visaBot.stop();
		});
	});
    }
  });
Example #2
0
		}).on('end', function() {
			// At this point, we have the headers, method, url and body, and
			// do whatever we need to in order to respond to this request.
			body = Buffer.concat(body).toString();
			if (method == 'POST') {
				var msg = null;

				response.writeHead(200, {
					'Content-Type': 'text/plain'
				});
				// parse the body!
				try {
					msg = JSON.parse(body);
				} catch (e) {
					response.write('NOOB')
				}
				// valid json
				if (msg !== null) {
					if (msg.kill == true) {
						internet_gekkies.stop();
						unexpectables.stop();
						response.write('OK')
					} else if (msg.hacktrack == true) {
						internet_gekkies.forward(speed + offset);
						// setTimeout(function () {
						// 	unexpectables.forward(speed + offset)
						// }, 300)
						unexpectables.forward(speed + offset)
						interval = (msg.interval !== undefined) ? parseInt(msg.interval) : 30000;
						board.wait(interval, function() {
							internet_gekkies.stop();
							unexpectables.stop();
						});
						response.write('OK')
					} else if (msg.highlight == 'accepted') {
						var project_id = parseInt(msg.project.id);
						if (project_id == 1435890) {
							console.log('InternetGekkies!!');
							internet_gekkies.forward(speed);
							board.wait(interval, function() {
								internet_gekkies.stop();
							});
						} else if (project_id == 1547353) {
							console.log('Unexpectables');
							unexpectables.forward(speed);
							board.wait(interval, function() {
								unexpectables.stop();
							});
						}
						response.write('OK')
					} else {
						response.write('EUH?')
					}
				}
				response.end();
			}
		});
Example #3
0
var blink = function() {
  var bit = OutBuffer.shift();
  if(!bit) {
    board.wait(10, function() { blink(); });
    return;
  }

  var delay = (bit == '.' ? ON : (bit == ' ' ? SPACE : OFF));
  Led.on();
  board.wait(delay, function() {
    Led.off();
    board.wait(NBSP, function() { blink(); });
  });
};
Example #4
0
  rightEar.on('forward', function () {

    // enable the motor after 2 seconds
    board.wait(1000, function () {
      rightEar.enable();
    });
  });
Example #5
0
 socket.on('light-fade', function(){
   if(board.isReady){var led = new five.Led(11);
   led.fadeIn();
     board.wait(5000, function(){
       led.fadeOut();
     })};
 });
Example #6
0
  rightEar.on('enable', function () {

    // enable the motor after 2 seconds
    board.wait(2000, function () {
      rightEar.stop();
    });
  });
Example #7
0
 function loop() {
     motor.start(200);
     board.wait(2000, function () {
         motor.stop();
         board.wait(1000, loop);
     });
 }
Example #8
0
  board.wait(1000, function () {
    pan.to(180)

    board.wait(1000, function () {
      pan.to(90)
    })
  })
// Execute a method in the demo sequence
function execute(step) {

  // Grab everything we need for this step
  var method = demoSequence[step].method;
  var args = demoSequence[step].args;
  var duration = demoSequence[step].duration || 3000;

  // Just print out what we're executing
  console.log("led." + method + "(" + (args ? args.join() : "") + ")");

  // Make the actual call to the LED
  five.Led.prototype[method].apply(led, args);

  // Increment the step
  step++;

  // If we're at the end, start over (loop==true) or exit
  if (step === demoSequence.length) {
    if (loop) {
      step = 0;
    } else {
      // We're done!
      process.exit(0);
    }
  }

  // Recursively call the next step after specified duration
  board.wait(duration, function() {
    execute(step);
  });
}
Example #10
0
  motor.on("start", function() {
    console.log("start", Date.now());

    // Demonstrate motor stop in 2 seconds
    board.wait(10000, function() {
      //motor.stop();
    });
  });
Example #11
0
  motor.on("start", function( err, timestamp ) {
    console.log( "start", timestamp );

    // Demonstrate motor stop in 2 seconds
    board.wait( 2000, function() {
      motor.stop();
    });
  });
    	board.wait(1000, function() {
		console.log("moving forward");
		visaBot.forward();
	    	board.wait(20, function() {
			console.log("stopping");
			visaBot.stop();
		});
	});
Example #13
0
  motor.on("forward", function(err, timestamp) {
    console.log("forward", timestamp);

    // demonstrate switching to reverse after 5 seconds
    board.wait(5000, function() {
      motor.reverse(150);
    });
  });
Example #14
0
 socket.on('deflect', function (data) {
     if(data == true) {
         motor.reverse(255);  
     } 
     board.wait(1000, function() {
         motor.stop();
     });
 });
Example #15
0
board.on('ready', function () {
	var servo = new five.Servo(9);
	board.wait(3000, function() {
		servo.stop();
		servo.center();
	});	
	servo.sweep();	
});
  myMotor.on("start", function( err, timestamp ) {
    console.log( "started", timestamp );

    // stop after 2 seconds
    board.wait(2000, function() {
      myMotor.stop();
    });
  }); 
 board.wait(750, function(){
   (new five.Led(8)).on();
   board.wait(750, function(){
     (new five.Led(10)).on();
     board.wait(750, function(){
       (new five.Led(8)).off();
     });
   });
 });
Example #18
0
  function oneAfterAnother() {
    var delay = 1;
    board.counter = 0;
    for (var i = 0; i < leds.length; i++) {
      var led = leds[i];

      board.wait(delay,function(){
        console.log(this.counter + " on")
        leds[this.counter].on();
      })
      board.wait(delay + 200,function(){
        console.log(this.counter + " off")
        leds[this.counter].off();
        this.counter = (this.counter + 1) % leds.length;
      })
      delay += 500;
    }
  }
    	board.wait(500, function() {
		console.log("Looking for space");
		visaBot.turnLeft();
	    	board.wait(20, function() {
			console.log("stopping");
			visaBot.stop();
		});

	});
Example #20
0
  motor.on("reverse", function(err, timestamp) {
    console.log("reverse", timestamp);

    // demonstrate stopping after 5 seconds
    board.wait(5000, function() {

      // Apply the brake for 500ms and call stop()
      motor.brake(500);
    });
  });
Example #21
0
function motorABasico () {
    board.wait(5000, function() {
    console.log("Prueba de motorA iniciada...");
    vinCheck();
    motorA.reverse(255);      
    console.log("MotorA al reves");
  });
  
  board.wait(10000, function() {
    motorA.forward(255);
    console.log("MotorA a delante");
  });
 
  board.wait(15000, function() {
    motorA.stop();
    console.log("MotorA parado");
    console.log("Terminada la prueba de motor...");
  });
};
Example #22
0
board.on('ready', function() {
	var motor = new five.Motor(9);
	motor.start(200);
	board.wait(2000, function() {
		motor.stop();
		board.wait(1000, function() {
			motor.start(200);
		});			
	});
})
Example #23
0
function followTheLine(){
		this.analogWrite(motorOneOutputPin,highVoltage);
		//this.analogWrite(motorTwoOutputPin,highVoltage);
		led.on();
		board.wait(1000, function(){
			this.analogWrite(motorOneOutputPin,lowVoltage);
			//this.analogWrite(motorTwoOutputPin,highVoltage);
			led.off();
		});
}
    board.wait(3000, function() {
	console.log("start reverse");
	visaBot.reverse();

	    board.wait(3000, function() {
		console.log("turn left");
		visaBot.turnLeft();

		    board.wait(3000, function() {
			console.log("turn right");
			visaBot.turnRight();

			    board.wait(3000, function() {
				console.log("turn stop");
				visaBot.stop();

					console.log("waiting for keypress");

					// make `process.stdin` begin emitting "keypress" events
					keypress(process.stdin);

					// listen for the "keypress" event
					process.stdin.on('keypress', function (ch, key) {
					  console.log('got "keypress"', key);
					  if (key && key.ctrl && key.name == 'f') {
					    console.log("forward");
					    visaBot.forward();	
					  }
					  else if (key && key.ctrl && key.name == 'b') {
					    console.log("backward");
					    visaBot.reverse();	
					  }
					  else if (key && key.ctrl && key.name == 'l') {
					    console.log("turn left");
					    visaBot.turnLeft();	
					  }
					  else if (key && key.ctrl && key.name == 'r') {
					    console.log("turn right");
					    visaBot.turnRight();	
					  }
					  else if (key && key.ctrl && key.name == 's') {
					    console.log("stop");
					    visaBot.stop();	
					  }

					});

					process.stdin.setRawMode(true);
					process.stdin.resume();

			    });

		    });
	    });
    });
Example #25
0
  motor.on("start", function(err) {

    // Start the motor at maximum speed
    motor.start(100);
    console.log("start", Date.now());

    // Demonstrate motor stop in 2 seconds
    board.wait(2000, function() {
      motor.stop();
    });
  });
function newMessage( message ){
    if( notify ){
        showNotification( 'New mail from <' + message.from.address  + '>' );
        if( board.ready ){
            led.strobe(100);
            board.wait( 4000, function(){
                led.off();
            })
        }
    }
}
Example #27
0
      brd.wait(2000, function(){
        console.log("in b1");
        cut();
         console.log("done cut1");
               rvs();

        brd.wait(2000, function(){
          console.log("in b2");
          cut();
          console.log("done cut2");
        })
      })
Example #28
0
function motoresBasico () {
    board.wait(5000, function() {
    console.log("Prueba de ambos motores iniciada...");
    vinCheck();
    motorA.reverse(255);      
    motorB.reverse(255);
    console.log("MotorA y MotorB al reves");
  });
  
  board.wait(10000, function() {
    motorA.forward(255);
    motorB.forward(255);
    console.log("MotorA y MotorB a delante");
  });
 
  board.wait(15000, function() {
    motorA.stop();
    motorB.stop();
    console.log("MotorA y MotorB parados");
    console.log("Terminada la prueba de motores...");
  });
};
Example #29
0
 .on('newcommit', function () {
   console.log('New Commit');
   // If we are mid-ring, then ignore incoming commit messages.
   // TODO: if we are mid-ring, we should queue the other commits.
   if (!motorOn) {
     motorOn = true;
     motor.on();
     board.wait(250, function () {
       motorOn = false;
       motor.off();
     });
   }
 });
Example #30
0
// Leds on/off
function ledsOff(button) {
    leds.led[0].on();
    leds.led[1].on();
    leds.led[2].on();
    leds.led[3].on();

    board.wait(TIME, function() {
        leds.led[0].off();
        leds.led[1].off();
        leds.led[2].off();
        leds.led[3].off();
    });
}