This gem provides a ruby frontend for SainSmart 16CH Relaycard, currently supported are only Network v2/v1 shields.
Add this line to your application's Gemfile:
gem 'sain_smart-network_IO'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sain_smart-network_IO
# get net relay instance (IP: "192.168.1.4")
r = SainSmart::NetworkIO::Relay.new(type: "16CH")
ch = r.channel(<Int>) # Get channel object
ch.on? # Is on? -> v2 only
ch.off? # Is off? -> v2 only
r.channels.each(&:on!) # Enable all
r.channels.each(&:off!) # Disable all
The gem is available as open source under the terms of the MIT License.