arduino_firmata 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +9 -0
- data/lib/arduino_firmata.rb +1 -1
- data/lib/arduino_firmata/arduino.rb +7 -0
- data/samples/README.md +1 -0
- data/samples/servo.rb +13 -0
- data/samples/sinatra_arduino.rb +2 -2
- metadata +4 -3
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
data/lib/arduino_firmata.rb
CHANGED
@@ -86,6 +86,13 @@ module ArduinoFirmata
|
|
86
86
|
write(value >> 7)
|
87
87
|
end
|
88
88
|
|
89
|
+
def servo_write(pin, angle)
|
90
|
+
pin_mode pin, SERVO
|
91
|
+
write(ANALOG_MESSAGE | (pin & 0x0F))
|
92
|
+
write(angle & 0x7F)
|
93
|
+
write(angle >> 7)
|
94
|
+
end
|
95
|
+
|
89
96
|
private
|
90
97
|
def write(cmd)
|
91
98
|
@serial.write_nonblock cmd.chr
|
data/samples/README.md
CHANGED
data/samples/servo.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#usr/bin/env ruby
|
2
|
+
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
|
3
|
+
require 'rubygems'
|
4
|
+
require 'arduino_firmata'
|
5
|
+
|
6
|
+
arduino = ArduinoFirmata.connect ARGV.shift
|
7
|
+
|
8
|
+
loop do
|
9
|
+
angle = rand 180
|
10
|
+
puts angle
|
11
|
+
arduino.servo_write 11, angle
|
12
|
+
sleep 1
|
13
|
+
end
|
data/samples/sinatra_arduino.rb
CHANGED
@@ -13,11 +13,11 @@ end
|
|
13
13
|
get '/on' do
|
14
14
|
analog = arduino.analog_read(0)
|
15
15
|
arduino.digital_write 13, ArduinoFirmata::HIGH
|
16
|
-
"<p>analog : #{analog}</p><p><a href='./off'>
|
16
|
+
"<p>analog : #{analog}</p><p><a href='./off'>LED OFF</a></p>"
|
17
17
|
end
|
18
18
|
|
19
19
|
get '/off' do
|
20
20
|
analog = arduino.analog_read(0)
|
21
21
|
arduino.digital_write 13, ArduinoFirmata::LOW
|
22
|
-
"<p>analog : #{analog}</p><p><a href='./on'>
|
22
|
+
"<p>analog : #{analog}</p><p><a href='./on'>LED ON</a></p>"
|
23
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arduino_firmata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: serialport
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- samples/led_blink.rb
|
111
111
|
- samples/led_fade.rb
|
112
112
|
- samples/on_changed.rb
|
113
|
+
- samples/servo.rb
|
113
114
|
- samples/sinatra_arduino.rb
|
114
115
|
- samples/tweet_temperature.rb
|
115
116
|
- script/console
|
@@ -135,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
136
|
version: '0'
|
136
137
|
segments:
|
137
138
|
- 0
|
138
|
-
hash: -
|
139
|
+
hash: -1305837009193017010
|
139
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
141
|
none: false
|
141
142
|
requirements:
|