Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var keypress = require("keypress");
- var Imp = require("imp-io");
- var five = require("johnny-five");
- var Sumobot = require("sumobot")(five);
- keypress(process.stdin);
- var board = new five.Board({
- io: new Imp({
- agent: "agent id"
- })
- });
- board.on("ready", function() {
- console.log("Welcome to Sumobot Jr: Light Bot!");
- var bot = new Sumobot({
- left: 1,
- right: 2,
- speed: 0.50
- });
- var light = new five.Sensor(5);
- // More light => higher resistance => lower ADC value
- // If the reading is < 512, it's in direct light
- light.booleanAt(512).on("data", function() {
- bot[this.boolean ? "stop" : "fwd"]();
- });
- // Ensure the bot is stopped
- bot.stop();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement