Skip to content

Instantly share code, notes, and snippets.

@scalone
Last active September 18, 2015 10:41
Show Gist options
  • Save scalone/3b3579ef22b916084432 to your computer and use it in GitHub Desktop.
Save scalone/3b3579ef22b916084432 to your computer and use it in GitHub Desktop.
require 'artoo'
connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
device :sphero, :driver => :sphero
connection :pebble, :adaptor => :pebble
device :watch, :driver => :pebble, :name => 'pebble'
api :host => '0.0.0.0', :port => '8080'
name 'pebble'
def move_forward
sphero.roll 100, 0; sphero.stop
end
def move_backward
sphero.roll 100, 180; sphero.stop
end
def button_push(*data)
case data[1]
when 'up' then
move_forward
when 'select' then
sphero.set_color(rand(255),rand(255),rand(255))
when 'down' then
move_backward
end
end
work do
on pebble, :button => :button_push
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment