Skip to content
/ gpio Public

gpio ruby gem allows for ruby code running on devices such as raspberry pi or systems with 1wire usb adapters to speak to the system's input/output pins. the end goal is for people to contribute code for specific devices, sensors and outputs.

Notifications You must be signed in to change notification settings

klappy/gpio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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}"

About

gpio ruby gem allows for ruby code running on devices such as raspberry pi or systems with 1wire usb adapters to speak to the system's input/output pins. the end goal is for people to contribute code for specific devices, sensors and outputs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages