Last active
September 18, 2015 10:34
-
-
Save scalone/2b0c1a2945f087d9d04a to your computer and use it in GitHub Desktop.
This file contains 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 '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