Created
November 12, 2008 16:55
-
-
Save atduskgreg/24204 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class ServoDrum < ArduinoSketch | |
output_pin 11, :as => :right, :device => :servo | |
output_pin 7, :as => :left, :device => :servo | |
serial_begin | |
@val = int | |
def loop | |
digitalWrite 13, ON | |
if serial_available | |
@val = serial_read | |
if @val == 'r' | |
right.position 140 | |
servo_delay 100 | |
serial_println "R" | |
right.position 110 | |
elsif @val == 'l' | |
left.position 140 | |
servo_delay 100 | |
serial_println "L" | |
left.position 110 | |
end | |
servo_delay 200 | |
end | |
end | |
def servo_delay(t) | |
t.times do | |
delay 1 | |
servo_refresh | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment