Class: Rotor::Servo
- Inherits:
-
Object
- Object
- Rotor::Servo
- Defined in:
- lib/rotor/servo.rb
Instance Method Summary collapse
-
#initialize(pin = 18) ⇒ Servo
constructor
A new instance of Servo.
- #rotate(direction) ⇒ Object
Constructor Details
#initialize(pin = 18) ⇒ Servo
Returns a new instance of Servo.
5 6 7 8 9 |
# File 'lib/rotor/servo.rb', line 5 def initialize(pin=18) @io = WiringPi::GPIO.new(WPI_MODE_GPIO) @pin = pin @io.mode @pin, OUTPUT end |
Instance Method Details
#rotate(direction) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rotor/servo.rb', line 11 def rotate(direction) if direction == :up freq = 1.0 elsif direction == :down freq = 2.0 else freq = 0.0 end 25.times do;pulser(freq,20.0);end end |