Skip to content

Instantly share code, notes, and snippets.

@msonnabaum
Created September 9, 2012 22:37
Show Gist options
  • Save msonnabaum/3687733 to your computer and use it in GitHub Desktop.
Save msonnabaum/3687733 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'serialport'
class Maestro
def initialize
@sp = SerialPort.new("/dev/ttyACM0")
end
def send(servo, position)
mess = "#{0x84.chr}#{servo.chr}#{(position & 0x7f).chr}#{((position >> 7) & 0x7F).chr}"
@sp.write mess
end
end
m = Maestro.new
loop do
(4000..8000).step(10) do |n|
m.send(0, n)
sleep 0.05
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment