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.23', {
- teamName: '',
- teamColor: '',
- game: ''
- })
- var steer = move()
- var arm = motor('d')
- function main (input) {
- if (input === 'f') {
- forward()
- } else if (input === 'b') {
- back()
- } else if (input === 'l') {
- left()
- } else if (input === 'r') {
- right()
- } else if (input === 's') {
- stop()
- } else if (input ==='d') {
- dance()
- } else if (input ==='spin') {
- spin()
- }else if (input ==='wave') {
- wave()
- }
- }
- function forward () {
- out('moving forward')
- steer.rotations(1, 40, 0)
- out('done')
- }
- function back () {
- out('moving back')
- steer.rotations(-1, 40, 0)
- out('done')
- }
- function left () {
- out('turning left')
- steer.rotations(1, 40, -55)
- out('done')
- }
- function right () {
- out('turning right')
- steer.rotations(1, 40, 55)
- out('done')
- }
- function stop () {
- out('stopping')
- steer.stop()
- out('done')
- }
- function dance () {
- forward()
- spin()
- back()
- spin()
- forward()
- spin()
- spin()
- spin()
- }
- function spin () {
- steer.rotations(3,100,70)
- }
- function wave () {
- arm.rotations(.2,100,20)
- }
Add Comment
Please, Sign In to add comment