Skip to content

jrmhaig/gpio_zero-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPIO Zero for Ruby

Quick setup

Ruby 2.3.3 is installed by default on the Raspberry Pi but there are a couple of other packages required:

sudo apt install ruby-bundler ruby-dev

To be able to install gems without root access it is necessary to set the location of gem files:

cat export GEM_PATH=~/.gems >> ~/.bashrc

Alternative setup

To use the latest version of Ruby a version manager such as RVM can be used. Note that this will build Ruby from source and on a Raspbery Pi version before 3 can take (literally) hours.

The RVM installer doesn't quite set itself up properly for Linux. This can be fixed with:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" >> ~/.bashrc

First steps

GPIO Zero depends on the pigpgiod daemon and so this need to be started first:

sudo /usr/bin/pigpiod

After that connect an LED up to pin 4 and try:

bundle install
bundle exec ruby test.rb

Documentation

Current features

  • LED, on and off

To do

Essentially, everything that exists in the Python GPIO Zero library, but in the short term the following features appear in the 'Basic Recipes' section of the documentation, ordered in (approximate) order of priority:

  • Other LED features. Eg, blink.
  • Button
  • PWMLED
  • Buzzer
  • RGBLED
  • MotionSensor
  • LightSensor
  • DistanceSensor
  • Motor
  • CPUTemperature
  • LEDBoard
  • LEDBarGraph
  • TrafficLights
  • FishDish
  • TrafficHat
  • Robot
  • MCP3008
  • Energenie
  • TimeOfDay
  • PingServer
  • tools.negated

For simplity, and as far as possible, the naming convention will follow the names in the Python libraries.

References

This project is based on the Python GPIO Zero libraries.

About

Simple GPIO access in Ruby for the Raspberry Pi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages