arduino_firmata 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -4
- data/Gemfile +3 -5
- data/History.txt +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +115 -0
- data/Rakefile +5 -24
- data/arduino_firmata.gemspec +21 -0
- data/lib/arduino_firmata.rb +1 -4
- data/lib/arduino_firmata/version.rb +4 -0
- data/samples/block.rb +1 -1
- data/test/test_arduino_firmata.rb +10 -1
- metadata +10 -81
- data/.gemtest +0 -0
- data/Gemfile.lock +0 -30
- data/Manifest.txt +0 -29
- data/README.rdoc +0 -126
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
data/.gitignore
CHANGED
@@ -1,5 +1,23 @@
|
|
1
|
-
|
1
|
+
.DS_Store
|
2
|
+
*.tmp
|
2
3
|
*~
|
3
|
-
|
4
|
-
|
5
|
-
.
|
4
|
+
*#*
|
5
|
+
vendor
|
6
|
+
.sass-cache
|
7
|
+
.bundle
|
8
|
+
config.yml
|
9
|
+
*.gem
|
10
|
+
*.rbc
|
11
|
+
.config
|
12
|
+
.yardoc
|
13
|
+
InstalledFiles
|
14
|
+
_yardoc
|
15
|
+
coverage
|
16
|
+
doc/
|
17
|
+
lib/bundler/man
|
18
|
+
pkg
|
19
|
+
rdoc
|
20
|
+
spec/reports
|
21
|
+
test/tmp
|
22
|
+
test/version_tmp
|
23
|
+
tmp
|
data/Gemfile
CHANGED
data/History.txt
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Sho Hashimoto
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
arduino_firmata
|
2
|
+
===============
|
3
|
+
|
4
|
+
* Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
|
5
|
+
* http://shokai.github.com/arduino_firmata
|
6
|
+
|
7
|
+
|
8
|
+
Install
|
9
|
+
-------
|
10
|
+
|
11
|
+
% gem install arduino_firmata
|
12
|
+
|
13
|
+
|
14
|
+
Requirements
|
15
|
+
------------
|
16
|
+
|
17
|
+
* Arduino Standard Firmata v2.2
|
18
|
+
* Arduino IDE -> [File] -> [Examples] -> [Firmata] -> [StandardFirmata]
|
19
|
+
* Ruby 1.8.7+
|
20
|
+
* Ruby 1.9.2+
|
21
|
+
|
22
|
+
|
23
|
+
Synopsis
|
24
|
+
--------
|
25
|
+
|
26
|
+
Setup
|
27
|
+
```ruby
|
28
|
+
require 'arduino_firmata'
|
29
|
+
|
30
|
+
arduino = ArduinoFirmata.connect # use default arduino
|
31
|
+
arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name'
|
32
|
+
arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name', :bps => 57600
|
33
|
+
```
|
34
|
+
|
35
|
+
Board Version
|
36
|
+
```ruby
|
37
|
+
puts "firmata version #{arduino.version}"
|
38
|
+
```
|
39
|
+
|
40
|
+
Digital Write
|
41
|
+
```ruby
|
42
|
+
arduino.digital_write 13, true
|
43
|
+
arduino.digital_write 13, false
|
44
|
+
```
|
45
|
+
|
46
|
+
Digital Read
|
47
|
+
```ruby
|
48
|
+
arduino.pin_mode 7, ArduinoFirmata::INPUT
|
49
|
+
puts arduino.digital_read 7 # => true/false
|
50
|
+
```
|
51
|
+
|
52
|
+
Analog Write (PWM)
|
53
|
+
```ruby
|
54
|
+
0.upto(255) do |i|
|
55
|
+
arduino.analog_write 11, i
|
56
|
+
sleep 0.01
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
Analog Read
|
61
|
+
```ruby
|
62
|
+
puts arduino.analog_read 0 # => 0 ~ 1023
|
63
|
+
|
64
|
+
arduino.on_analog_changed 0 do |value|
|
65
|
+
puts value # => 0 ~ 1023
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
Servo Motor
|
70
|
+
```ruby
|
71
|
+
loop do
|
72
|
+
angle = rand(180)
|
73
|
+
arduino.servo_write 11, angle
|
74
|
+
sleep 1
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
Close
|
79
|
+
```ruby
|
80
|
+
arduino.close
|
81
|
+
```
|
82
|
+
|
83
|
+
Block
|
84
|
+
```ruby
|
85
|
+
ArduinoFirmata.connect do
|
86
|
+
puts "firmata version #{version}"
|
87
|
+
|
88
|
+
30.times do
|
89
|
+
an = analog_read 0
|
90
|
+
analog_write 11, an
|
91
|
+
sleep 0.01
|
92
|
+
end
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
|
97
|
+
see samples https://github.com/shokai/arduino_firmata/tree/master/samples
|
98
|
+
|
99
|
+
|
100
|
+
Test
|
101
|
+
----
|
102
|
+
|
103
|
+
% gem install bundler
|
104
|
+
% bundle install
|
105
|
+
% export ARDUINO=/dev/tty.usb-device-name
|
106
|
+
% rake test
|
107
|
+
|
108
|
+
|
109
|
+
Contributing
|
110
|
+
------------
|
111
|
+
1. Fork it
|
112
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
113
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
114
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
115
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,27 +1,8 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'hoe'
|
4
|
-
require 'fileutils'
|
5
|
-
require './lib/arduino_firmata'
|
6
|
-
|
7
|
-
Hoe.plugin :newgem
|
8
|
-
# Hoe.plugin :website
|
9
|
-
# Hoe.plugin :cucumberfeatures
|
10
|
-
|
11
|
-
# Generate all the Rake tasks
|
12
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
-
$hoe = Hoe.spec 'arduino_firmata' do
|
14
|
-
self.developer 'Sho Hashimoto', 'hashimoto@shokai.org'
|
15
|
-
#self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
16
|
-
self.rubyforge_name = self.name # TODO this is default value
|
17
|
-
self.extra_deps = [['serialport','>= 1.1.0', '< 2.0.0'],
|
18
|
-
['args_parser','>= 0.1.2', '< 1.0.0']]
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
19
3
|
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.pattern = "test/test_*.rb"
|
20
6
|
end
|
21
7
|
|
22
|
-
|
23
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
24
|
-
|
25
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
26
|
-
# remove_task :default
|
27
|
-
# task :default => [:spec, :features]
|
8
|
+
task :default => :test
|
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'arduino_firmata/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "arduino_firmata"
|
7
|
+
gem.version = ArduinoFirmata::VERSION
|
8
|
+
gem.authors = ["Sho Hashimoto"]
|
9
|
+
gem.email = ["hashimoto@shokai.org"]
|
10
|
+
gem.description = %q{Arduino Firmata protocol (http://firmata.org) implementation on Ruby.}
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.homepage = "http://shokai.github.com/arduino_firmata"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/).reject{|i| i=="Gemfile.lock" }
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_dependency 'serialport', '>= 1.1.0'
|
20
|
+
gem.add_dependency 'args_parser', '>= 0.1.2'
|
21
|
+
end
|
data/lib/arduino_firmata.rb
CHANGED
data/samples/block.rb
CHANGED
@@ -13,7 +13,16 @@ class TestArduinoFirmata < MiniTest::Unit::TestCase
|
|
13
13
|
|
14
14
|
def test_analog_read
|
15
15
|
0.upto(5).each do |pin|
|
16
|
-
|
16
|
+
ain = @arduino.analog_read pin
|
17
|
+
assert 0 <= ain and ain < 1024
|
18
|
+
end
|
19
|
+
@arduino.close
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_digital_read
|
23
|
+
0.upto(13).each do |pin|
|
24
|
+
din = @arduino.digital_read pin
|
25
|
+
assert [true,false].include? din
|
17
26
|
end
|
18
27
|
@arduino.close
|
19
28
|
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.7
|
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:
|
12
|
+
date: 2013-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: serialport
|
@@ -19,9 +19,6 @@ dependencies:
|
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 1.1.0
|
22
|
-
- - <
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 2.0.0
|
25
22
|
type: :runtime
|
26
23
|
prerelease: false
|
27
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,9 +27,6 @@ dependencies:
|
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 1.1.0
|
33
|
-
- - <
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 2.0.0
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
31
|
name: args_parser
|
38
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,9 +35,6 @@ dependencies:
|
|
41
35
|
- - ! '>='
|
42
36
|
- !ruby/object:Gem::Version
|
43
37
|
version: 0.1.2
|
44
|
-
- - <
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 1.0.0
|
47
38
|
type: :runtime
|
48
39
|
prerelease: false
|
49
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,81 +43,28 @@ dependencies:
|
|
52
43
|
- - ! '>='
|
53
44
|
- !ruby/object:Gem::Version
|
54
45
|
version: 0.1.2
|
55
|
-
- - <
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: 1.0.0
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: rdoc
|
60
|
-
requirement: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '3.10'
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
|
-
requirements:
|
71
|
-
- - ~>
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '3.10'
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: newgem
|
76
|
-
requirement: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
|
-
requirements:
|
79
|
-
- - ! '>='
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 1.5.3
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
|
-
requirements:
|
87
|
-
- - ! '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.5.3
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: hoe
|
92
|
-
requirement: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
|
-
requirements:
|
95
|
-
- - ~>
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '3.1'
|
98
|
-
type: :development
|
99
|
-
prerelease: false
|
100
|
-
version_requirements: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
|
-
requirements:
|
103
|
-
- - ~>
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '3.1'
|
106
46
|
description: Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
|
107
47
|
email:
|
108
48
|
- hashimoto@shokai.org
|
109
49
|
executables:
|
110
50
|
- arduino_firmata
|
111
51
|
extensions: []
|
112
|
-
extra_rdoc_files:
|
113
|
-
- History.txt
|
114
|
-
- Manifest.txt
|
115
|
-
- README.rdoc
|
52
|
+
extra_rdoc_files: []
|
116
53
|
files:
|
117
54
|
- .gitignore
|
118
55
|
- Gemfile
|
119
|
-
- Gemfile.lock
|
120
56
|
- History.txt
|
121
|
-
-
|
122
|
-
- README.
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
123
59
|
- Rakefile
|
60
|
+
- arduino_firmata.gemspec
|
124
61
|
- bin/arduino_firmata
|
125
62
|
- lib/arduino_firmata.rb
|
126
63
|
- lib/arduino_firmata/arduino.rb
|
127
64
|
- lib/arduino_firmata/const.rb
|
128
65
|
- lib/arduino_firmata/event.rb
|
129
66
|
- lib/arduino_firmata/main.rb
|
67
|
+
- lib/arduino_firmata/version.rb
|
130
68
|
- samples/README.md
|
131
69
|
- samples/analog_read_write.rb
|
132
70
|
- samples/block.rb
|
@@ -137,20 +75,14 @@ files:
|
|
137
75
|
- samples/servo.rb
|
138
76
|
- samples/sinatra_arduino.rb
|
139
77
|
- samples/tweet_temperature.rb
|
140
|
-
- script/console
|
141
|
-
- script/destroy
|
142
|
-
- script/generate
|
143
78
|
- test/test_arduino_firmata.rb
|
144
79
|
- test/test_block.rb
|
145
|
-
- test/test_helper.rb
|
146
80
|
- test/test_classmethods.rb
|
147
|
-
- .
|
81
|
+
- test/test_helper.rb
|
148
82
|
homepage: http://shokai.github.com/arduino_firmata
|
149
83
|
licenses: []
|
150
84
|
post_install_message:
|
151
|
-
rdoc_options:
|
152
|
-
- --main
|
153
|
-
- README.rdoc
|
85
|
+
rdoc_options: []
|
154
86
|
require_paths:
|
155
87
|
- lib
|
156
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -159,9 +91,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
91
|
- - ! '>='
|
160
92
|
- !ruby/object:Gem::Version
|
161
93
|
version: '0'
|
162
|
-
segments:
|
163
|
-
- 0
|
164
|
-
hash: 4489983546483547192
|
165
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
95
|
none: false
|
167
96
|
requirements:
|
@@ -169,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
98
|
- !ruby/object:Gem::Version
|
170
99
|
version: '0'
|
171
100
|
requirements: []
|
172
|
-
rubyforge_project:
|
101
|
+
rubyforge_project:
|
173
102
|
rubygems_version: 1.8.24
|
174
103
|
signing_key:
|
175
104
|
specification_version: 3
|
data/.gemtest
DELETED
File without changes
|
data/Gemfile.lock
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
RedCloth (4.2.9)
|
5
|
-
activesupport (2.3.14)
|
6
|
-
args_parser (0.1.2)
|
7
|
-
hoe (3.1.0)
|
8
|
-
rake (~> 0.8)
|
9
|
-
minitest (4.1.0)
|
10
|
-
newgem (1.5.3)
|
11
|
-
RedCloth (>= 4.1.1)
|
12
|
-
activesupport (~> 2.3.4)
|
13
|
-
hoe (>= 2.4.0)
|
14
|
-
rubigen (>= 1.5.3)
|
15
|
-
syntax (>= 1.0.0)
|
16
|
-
rake (0.9.2.2)
|
17
|
-
rubigen (1.5.8)
|
18
|
-
activesupport (>= 2.3.5, < 3.2.0)
|
19
|
-
serialport (1.1.0)
|
20
|
-
syntax (1.0.0)
|
21
|
-
|
22
|
-
PLATFORMS
|
23
|
-
ruby
|
24
|
-
|
25
|
-
DEPENDENCIES
|
26
|
-
args_parser
|
27
|
-
hoe
|
28
|
-
minitest
|
29
|
-
newgem
|
30
|
-
serialport
|
data/Manifest.txt
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
.gitignore
|
2
|
-
Gemfile
|
3
|
-
Gemfile.lock
|
4
|
-
History.txt
|
5
|
-
Manifest.txt
|
6
|
-
README.rdoc
|
7
|
-
Rakefile
|
8
|
-
bin/arduino_firmata
|
9
|
-
lib/arduino_firmata.rb
|
10
|
-
lib/arduino_firmata/arduino.rb
|
11
|
-
lib/arduino_firmata/const.rb
|
12
|
-
lib/arduino_firmata/event.rb
|
13
|
-
lib/arduino_firmata/main.rb
|
14
|
-
samples/README.md
|
15
|
-
samples/analog_read_write.rb
|
16
|
-
samples/block.rb
|
17
|
-
samples/digital_read.rb
|
18
|
-
samples/led_blink.rb
|
19
|
-
samples/led_fade.rb
|
20
|
-
samples/on_changed.rb
|
21
|
-
samples/servo.rb
|
22
|
-
samples/sinatra_arduino.rb
|
23
|
-
samples/tweet_temperature.rb
|
24
|
-
script/console
|
25
|
-
script/destroy
|
26
|
-
script/generate
|
27
|
-
test/test_arduino_firmata.rb
|
28
|
-
test/test_block.rb
|
29
|
-
test/test_helper.rb
|
data/README.rdoc
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
= arduino_firmata
|
2
|
-
|
3
|
-
* http://shokai.github.com/arduino_firmata
|
4
|
-
|
5
|
-
== INSTALL:
|
6
|
-
|
7
|
-
* gem install arduino_firmata
|
8
|
-
|
9
|
-
== DESCRIPTION:
|
10
|
-
|
11
|
-
Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
|
12
|
-
|
13
|
-
== REQUIREMENTS:
|
14
|
-
|
15
|
-
* Arduino Standard Firmata v2.2
|
16
|
-
Arduino IDE -> [File] -> [Examples] -> [Firmata] -> [StandardFirmata]
|
17
|
-
|
18
|
-
* Ruby 1.8.7+
|
19
|
-
* Ruby 1.9.2+
|
20
|
-
|
21
|
-
== SYNOPSIS:
|
22
|
-
|
23
|
-
Setup
|
24
|
-
|
25
|
-
require 'arduino_firmata'
|
26
|
-
|
27
|
-
arduino = ArduinoFirmata.connect # use default arduino
|
28
|
-
arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name'
|
29
|
-
|
30
|
-
|
31
|
-
Board Version
|
32
|
-
|
33
|
-
puts "firmata version #{arduino.version}"
|
34
|
-
|
35
|
-
|
36
|
-
Digital Write
|
37
|
-
|
38
|
-
arduino.digital_write 13, true
|
39
|
-
arduino.digital_write 13, false
|
40
|
-
|
41
|
-
|
42
|
-
Digital Read
|
43
|
-
|
44
|
-
arduino.pin_mode 7, ArduinoFirmata::INPUT
|
45
|
-
puts arduino.digital_read 7 # => true/false
|
46
|
-
|
47
|
-
|
48
|
-
Analog Write (PWM)
|
49
|
-
|
50
|
-
0.upto(255) do |i|
|
51
|
-
arduino.analog_write 11, i
|
52
|
-
sleep 0.01
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
Analog Read
|
57
|
-
|
58
|
-
puts arduino.analog_read 0 # => 0 ~ 1023
|
59
|
-
|
60
|
-
arduino.on_analog_changed 0 do |value|
|
61
|
-
puts value # => 0 ~ 1023
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
Servo Motor
|
66
|
-
|
67
|
-
loop do
|
68
|
-
angle = rand(180)
|
69
|
-
arduino.servo_write 11, angle
|
70
|
-
sleep 1
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
Close
|
75
|
-
|
76
|
-
arduino.close
|
77
|
-
|
78
|
-
|
79
|
-
Block
|
80
|
-
|
81
|
-
ArduinoFirmata.connect do
|
82
|
-
puts "firmata version #{version}"
|
83
|
-
|
84
|
-
30.times do
|
85
|
-
an = analog_read 0
|
86
|
-
analog_write 11, an
|
87
|
-
sleep 0.01
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
see samples https://github.com/shokai/arduino_firmata/tree/master/samples
|
94
|
-
|
95
|
-
|
96
|
-
== TEST:
|
97
|
-
|
98
|
-
% gem install bundler
|
99
|
-
% bundle install
|
100
|
-
% export ARDUINO=/dev/tty.usb-device-name
|
101
|
-
% rake test
|
102
|
-
|
103
|
-
== LICENSE:
|
104
|
-
|
105
|
-
(The MIT License)
|
106
|
-
|
107
|
-
Copyright (c) 2012 Sho Hashimoto
|
108
|
-
|
109
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
110
|
-
a copy of this software and associated documentation files (the
|
111
|
-
'Software'), to deal in the Software without restriction, including
|
112
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
113
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
114
|
-
permit persons to whom the Software is furnished to do so, subject to
|
115
|
-
the following conditions:
|
116
|
-
|
117
|
-
The above copyright notice and this permission notice shall be
|
118
|
-
included in all copies or substantial portions of the Software.
|
119
|
-
|
120
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
121
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
122
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
123
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
124
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
125
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
126
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/script/console
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: script/console
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/arduino_firmata.rb'}"
|
9
|
-
puts "Loading arduino_firmata gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|