Coder Social home page Coder Social logo

grovepi's Introduction

GrovePi for Ruby

Unofficial bindings for the GrovePi library, allowing you to write your Raspberry Pi software for GrovePi+ in Ruby!

Installation

Add this line to your application's Gemfile:

gem 'grovepi'

And then execute:

$ bundle

Or install it yourself as:

$ gem install grovepi

Usage

Read the current temperature:

Grovepi.temperature # => 70

Read the current pH level:

Grovepi.ph # => 6.83

Turn the LED on and off:

Grovepi.led.active = true
Grovepi.led.active? # => true
Grovepi.led.active = false
Grovepi.led.active? # => false

Low-level API

You can also use the "low-level" API to do raw digital and analog reads/writes on the device.

For example, here is how to perform the above LED functions with the low-level digitalWrite and digitalRead calls:

# the LED is off..
Grovepi.digital_read(4)     # => 0
# send data bit 1 to port D4 to turn on the LED
Grovepi.digital_write(4,1)
Grovepi.digital_read(4)     # => 1
# the LED is now on. send data bit 0 to port D4 to turn off the LED
Grovepi.digital_write(4,0)
Grovepi.digital_read(4)     # => 0

Development

This gem requires an installation of Raspbian, and therefore cannot be compiled on most machines. Provided in this repo is a Dockerfile which describes how to build a Docker container locally for gem testing.

To build the gem into a Docker container, run:

docker build .

When that's done, you can now run tests in your container:

docker run 'bin/rake test'

You can also get a console in your container:

docker run 'bin/console'

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tubbo/grovepi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

This Ruby gem is available as open source under the terms of the MIT License. The GrovePi C++ code is Copyright (C) 2017 Dexter Industries.

Code of Conduct

Everyone interacting in the Grovepi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

grovepi's People

Watchers

 avatar  avatar

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.