Giter Club home page Giter Club logo

gpio's Introduction

description

====

a ruby gem and repository to contribute gpio code for devices such as Raspberry Pi to read sensors and control outputs.

gpio allows for devices such as raspberry pi or systems with 1wire usb adapters to speak to the system's input/output pins.

installation

====

bundler

using bundler, add this to your Gemfile in the root of your app

gem 'gpio'

install bundler and then run bundle install

gem install bundler
bundle install

gem install

from command line

gem install gpio

require in your ruby file

require 'gpio'

example

====

let's setup a motion sensor on GPIO pin 17 on a RaspberryPi (default).

motion = GPIO::MotionDetector.new(pin: 17)

do we detect and motion yet?

motion.detect

let's print a message corresponding to the motion.detect?

puts motion.detect ? "Motion detected!" : "No motion detected."

was the value any different than the last time it detected?

motion.changed?
puts "last: #{motion.last_reading}, current: #{motion.reading}"

wait until the value changes before we move on.

until motion.changed? do
	motion.detect
	sleep 0.5
end
puts "Something changed!"
puts "last: #{motion.last_reading}, current: #{motion.reading}"

gpio's People

Contributors

5v3n avatar galp avatar klappy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpio's Issues

Errno::ENOENT: No such file or directory - /sys/class/gpio/gpio17/value

root@raspberrypi:# ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [arm-linux-eabihf]
root@raspberrypi:
# gem install gpio
Fetching: gpio-0.0.6.gem (100%)
Successfully installed gpio-0.0.6
1 gem installed
Installing ri documentation for gpio-0.0.6...
Installing RDoc documentation for gpio-0.0.6...
root@raspberrypi:~# irb
irb(main):001:0> require 'gpio'
=> true
irb(main):002:0> motion = GPIO::MotionDetector.new(pin: 17)
Errno::ENOENT: No such file or directory - /sys/class/gpio/gpio17/value
from /var/lib/gems/1.9.1/gems/gpio-0.0.6/lib/gpio/device.rb:50:in initialize' from /var/lib/gems/1.9.1/gems/gpio-0.0.6/lib/gpio/device.rb:50:innew'
from /var/lib/gems/1.9.1/gems/gpio-0.0.6/lib/gpio/device.rb:50:in pin_file' from /var/lib/gems/1.9.1/gems/gpio-0.0.6/lib/gpio/pin.rb:16:ininitialize'
from /var/lib/gems/1.9.1/gems/gpio-0.0.6/lib/gpio/pins/input_pin.rb:6:in initialize' from /var/lib/gems/1.9.1/gems/gpio-0.0.6/lib/gpio/sensor.rb:5:innew'
from /var/lib/gems/1.9.1/gems/gpio-0.0.6/lib/gpio/sensor.rb:5:in initialize' from (irb):2:innew'
from (irb):2
from /usr/bin/irb:12:in `

'
irb(main):003:0>

Add license information

Currently the project does not specify license information for the code. Please do it.

and also add "gem.license ='XXX'" license information to the gemspec.

Rubygems version is different to github version

It looks like the commit that added the lib/gpio/outputs folder was on June 13th, but the version number wasn't bumped past 0.0.6. The version on rubygems is 0.0.6 but dates from June 8th, which is missing the outputs folder.

This means that the documentation on GH and the gem are a little out of sync :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.