{"id":14978063,"url":"https://github.com/theovidal/raspi-gpio-rb","last_synced_at":"2025-03-29T18:31:07.550Z","repository":{"id":56890988,"uuid":"171748366","full_name":"theovidal/raspi-gpio-rb","owner":"theovidal","description":"🔌 Simple \u0026 light interface to interact with Raspberry Pi GPIO pins","archived":true,"fork":false,"pushed_at":"2023-06-22T14:47:07.000Z","size":591,"stargazers_count":14,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T20:51:11.885Z","etag":null,"topics":["gpio-pins","raspberry-pi","ruby","rubygem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theovidal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-02-20T20:59:44.000Z","updated_at":"2025-02-12T07:48:49.000Z","dependencies_parsed_at":"2022-08-20T16:01:04.431Z","dependency_job_id":"e5c683e0-c52c-4393-b971-359ad8ab782d","html_url":"https://github.com/theovidal/raspi-gpio-rb","commit_stats":null,"previous_names":["exybore/raspi-gpio-rb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fraspi-gpio-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fraspi-gpio-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fraspi-gpio-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fraspi-gpio-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theovidal","download_url":"https://codeload.github.com/theovidal/raspi-gpio-rb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246226868,"owners_count":20743838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpio-pins","raspberry-pi","ruby","rubygem"],"created_at":"2024-09-24T13:56:48.570Z","updated_at":"2025-03-29T18:31:07.174Z","avatar_url":"https://github.com/theovidal.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"banner.png\" alt=\"banner\"\u003e\n  \u003ch1\u003eraspi-gpio-rb\u003c/h1\u003e\n  \u003ch3\u003e🔌 A simple and light interface to interact with GPIO pins of the Raspberry Pi.\u003c/h3\u003e\n\u003c/div\u003e\n\nThis library uses /sys/class/gpio interface to communicate with GPIO pins. It doesn't require super-user rights, therefore everyone on the OS can use it.\n\n- [📌 Requirements](#-requirements)\n- [🔧 Setup](#-setup)\n  - [Quick installation](#quick-installation)\n  - [Gemfile](#gemfile)\n  - [Build](#build)\n- [⌨ Basic interactions](#-basic-interactions)\n  - [Defining a pin](#defining-a-pin)\n  - [Reading pin's value](#reading-pins-value)\n  - [Outputing a value](#outputing-a-value)\n- [🔐 License](#-license)\n\n## 📌 Requirements\n\nThis library requires an updated version of Ruby, and a Raspberry Pi with Raspbian installed on.\n\nThe raspi-gpio library has been tested on models : 3B\n\n## 🔧 Setup\n\n### Quick installation\n\nIf you want to quickly test the library, you can install it using the `install` command of Ruby Gem.\n\n```bash\ngem install raspi-gpio\n```\n\n### Gemfile\n\nIf you setup the library for medium or big projects, it's recommended to write it in your Gemfile.\n\n```gemfile\ngem 'raspi-gpio', '~\u003e 1.0'\n```\n\nAfter, use again the `install` command, but without the package name.\n\n```bash\ngem install\n```\n\n### Build\n\nYou can also compile it by yourself. First, clone the repository.\n\n```bash\ngit clone https://github.com/exybore/raspi-gpio-rb.git  # HTTP\n          git@github.com:exybore/raspi-gpio-rb.git      # SSH\n```\n\nThen, build the gemspec file to create the gem.\n\n```bash\ngem build ./raspi-gpio.gemspec\n```\n\nFinally, install it on your system.\n\n```bash\ngem install ./raspi-gpio-1.x.x.gem\n```\n\n## ⌨ Basic interactions\n\nFirst of all, we must include the library in our project. That can be achieved really easily with the `require` keyword.\n\n```ruby\nrequire 'raspi-gpio'\n\n# ...\n```\n\n### Defining a pin\n\nA GPIO pin is defined with three things :\n\n- a pin number (the number of total pins depend on your Raspberry model)\n- a direction (in or out)\n- a value (low or high)\n\nThe `GPIO` class is the way the library provides to register our pins. The initialization method takes 2 arguments :\n\n- the pin number to use\n- the direction (default : out)\n\nWe can use the `OUT` and `IN` constants for the direction.\n\n```ruby\npin = GPIO.new(9, OUT)\n```\n\nThe direction of a pin can be changed at any point of the code using the `set_mode` method.\n\n```ruby\npin.set_mode(IN)\n```\n\n### Reading pin's value\n\nTo read the pin value, we're going to use the `get_value` method.\n\n```ruby\npin.get_value\n\n# Example output : 0\n```\n\n- If the pin direction is `IN`, it'll read the power that goes into it\n- If it's in `OUT`, it'll output the value that we defined earlier\n\n### Outputing a value\n\nTo set the value of a pin, the GPIO class has a `set_value` method that can take two values :\n\n- 0, no power (low)\n- 1, maximum power (high)\n\nThe `LOW` and `HIGH` constants are here to let us set them while keeping code clarity.\n\n```ruby\n# Imagine that a LED is connected to our pin.\n\npin.set_value(HIGH)\n\n# Output : the LED is on\n\npin.set_value(LOW)\n\n# Output : the LED is off\n```\n\n## 🔐 License\n\nSee the [license file](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheovidal%2Fraspi-gpio-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheovidal%2Fraspi-gpio-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheovidal%2Fraspi-gpio-rb/lists"}