Created
August 12, 2013 21:19
-
-
Save karledurante/6215387 to your computer and use it in GitHub Desktop.
RubyLoco Hack Night: Sphero!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sphero' | |
require 'pry' | |
FORWARD = 0 | |
RIGHT = 90 | |
BACKWARD = 180 | |
LEFT = 270 | |
SLOW = 100 | |
FAST = 200 | |
tty = `ls -d /dev/* | grep tty.Sphero`.chomp | |
puts "Connecting to #{tty}" | |
Sphero.start tty do | |
puts ping | |
binding.pry | |
# you will now be kicked into an "irb" like session where you can use the commands: | |
# roll FORWARD, SLOW | |
# stop | |
end |
# simple circle program
require 'sphero'
require './common'
FORWARD = 0
RIGHT = 90
BACKWARD = 180
LEFT = 270
SLOW = 100
FAST = 200
# you're sphero's serial port
tty = '/dev/tty.Sphero-RWR-RN-SPP'
Sphero.start tty do
puts ping
roll SLOW, FORWARD
keep_going 1
roll SLOW, RIGHT
keep_going 1
roll SLOW, BACKWARD
keep_going 1
roll SLOW, LEFT
keep_going 1
roll SLOW, FORWARD
keep_going 1
stop
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"ping" the sphero and output the result so you know you're connected:
puts sphero.ping