Guest User

Untitled

a guest
Oct 22nd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. var {loop, move, motor, read, sleep, out} = require('robot-loop')
  2. loop(main, '192.168.1.23', {
  3. teamName: '',
  4. teamColor: '',
  5. game: ''
  6. })
  7.  
  8. var steer = move()
  9. var arm = motor('d')
  10.  
  11. function main (input) {
  12. if (input === 'f') {
  13. forward()
  14. } else if (input === 'b') {
  15. back()
  16. } else if (input === 'l') {
  17. left()
  18. } else if (input === 'r') {
  19. right()
  20. } else if (input === 's') {
  21. stop()
  22. } else if (input ==='d') {
  23. dance()
  24. } else if (input ==='spin') {
  25. spin()
  26. }else if (input ==='wave') {
  27. wave()
  28. }
  29. }
  30. function forward () {
  31. out('moving forward')
  32. steer.rotations(1, 40, 0)
  33. out('done')
  34. }
  35.  
  36. function back () {
  37. out('moving back')
  38. steer.rotations(-1, 40, 0)
  39. out('done')
  40. }
  41.  
  42. function left () {
  43. out('turning left')
  44. steer.rotations(1, 40, -55)
  45. out('done')
  46. }
  47.  
  48. function right () {
  49. out('turning right')
  50. steer.rotations(1, 40, 55)
  51. out('done')
  52. }
  53.  
  54. function stop () {
  55. out('stopping')
  56. steer.stop()
  57. out('done')
  58. }
  59. function dance () {
  60. forward()
  61. spin()
  62. back()
  63. spin()
  64. forward()
  65. spin()
  66. spin()
  67. spin()
  68. }
  69. function spin () {
  70. steer.rotations(3,100,70)
  71. }
  72.  
  73. function wave () {
  74. arm.rotations(.2,100,20)
  75.  
  76. }
Add Comment
Please, Sign In to add comment