Drivers

Artoo has a extensible system for connecting to hardware devices.

Continuous Servo


Provides an interface for making servos easy to work and interact with from Artoo.

How To Connect

For Arduino:

require 'artoo'
connection :arduino, :adaptor => :firmata, :port => '127.0.0.1:8023'
device :servo, :driver => :servo, :pin => 3 # pin must be a PWM pin

For Digispark:

require 'artoo'
connection :digispark, :adaptor => :littlewire, :vendor => 0x1781, :product => 0x0c9f
device :servo, :driver => :servo, :pin => 3 # pin must be a PWM pin

How To Use

Example moves a servo from angle 0 to 90 to 180.

require 'artoo'

# Circuit and schematic here: http://arduino.cc/en/Tutorial/Sweep

#connection :arduino, :adaptor => :firmata, :port => '/dev/tty*'
connection :arduino, :adaptor => :firmata, :port => '127.0.0.1:8023'
device :board, :driver => :device_info
device :servo, :driver => :servo, :pin => 3 # pin must be a PWM pin

work do
  puts "Firmware name: #{board.firmware_name}"
  puts "Firmata version: #{board.version}"

  servo.move(0) # reset the position of the sweep (same as servo.min)

  every(2) do
    case servo.current_angle
    when 0 then servo.center
    when 90 then servo.max
    when 180 then servo.min
    end
  end
end

Commands

clockwise

Turns the servo to go clockwise, if the driver is continuous.

Params

no params

Returns

nil

counter_clockwise

Turns the servo to go counter clockwise, if the driver is continuous.

Params

no params

Returns

nil

stop

Stops the driver.

Params

no params

Returns

nil

Circuit

Compatibility

Important Note: You need to install pi-blaster in the raspberry-pi, this project enables PWM in the GPIO pins .