Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var {loop, move, motor, read, sleep, out} = require('robot-loop')
- loop(main, '192.168.1.159', {
- teamName: '',
- teamColor: '',
- game: ''
- })
- var steer = move()
- function main (input, rot) {
- if (input === 'forward') {
- forward(rot)
- } else if (input === 'back') {
- back(rot)
- } else if (input === 'left') {
- left(rot)
- } else if (input === 'right') {
- right(rot)
- }
- }
- function forward (rot) {
- out('moving forward')
- steer.rotations(rot, 40, 0)
- out('done')
- }
- function back (rot) {
- out('moving back')
- steer.rotations(-rot, 40, 0)
- out('done')
- }
- function left (rot) {
- out('turning left')
- steer.rotations(1, 40, -rot)
- out('done')
- }
- function right (rot) {
- out('turning right')
- steer.rotations(1, 40, rot)
- out('done')
- }
Add Comment
Please, Sign In to add comment