Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. var keypress = require("keypress");
  2. var Imp = require("imp-io");
  3. var five = require("johnny-five");
  4. var Sumobot = require("sumobot")(five);
  5.  
  6. keypress(process.stdin);
  7.  
  8. var board = new five.Board({
  9. io: new Imp({
  10. agent: "agent id"
  11. })
  12. });
  13.  
  14. board.on("ready", function() {
  15.  
  16. console.log("Welcome to Sumobot Jr: Light Bot!");
  17.  
  18. var bot = new Sumobot({
  19. left: 1,
  20. right: 2,
  21. speed: 0.50
  22. });
  23.  
  24. var light = new five.Sensor(5);
  25.  
  26. // More light => higher resistance => lower ADC value
  27. // If the reading is < 512, it's in direct light
  28. light.booleanAt(512).on("data", function() {
  29. bot[this.boolean ? "stop" : "fwd"]();
  30. });
  31.  
  32. // Ensure the bot is stopped
  33. bot.stop();
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement