Giter VIP home page Giter VIP logo

freebsd-gpio's Introduction

freebsd-gpio

Simple wrappers around FreeBSD's GPIO ioctl for Per, Python, and Ruby

Perl

Build

perl Makefile.PL
make
make install

Example

use GPIO;

my $controller = GPIO->new();
$controller->open() or die("Can't open GPIO controller dev: $!");


# config pin
$controller->set_pin_config(16, GPIO::PIN_OUTPUT);

# pin LOW, LED is on
$controller->set_pin_value(16, GPIO::LOW);
sleep(1);

# pin HIGH, LED is on
$controller->set_pin_value(16, GPIO::HIGH);

Python

Build

python setup.py build
python setup.py install

Example

from time import sleep
import gpio

gpioc = gpio.controller()

led_pin = gpioc.pin(16)
# config pin
led_pin.config = gpio.PIN_OUTPUT

# pin LOW, LED is on
led_pin.value = gpio.LOW
sleep(1);

# pin HIGH, LED is off
led_pin.value = gpio.HIGH

Ruby

Build

gem build gpio.gemspec
gem install ./gpio-0.0.1.gem

Example

require 'gpio'

gpioc = GpioController.new("/dev/gpioc0")

led_pin = gpioc.pin(16)
# config pin
led_pin.config = GPIO_PIN_OUTPUT

# pin LOW, led is ON
led_pin.value = GPIO_LOW
sleep(1)

# pin HIGH, led is OFF
led_pin.value = GPIO_HIGH

Examples

Each subdirectory contains demo script (rpi-gpio-demo) for Raspberry Pi written in respective language. It simply dumps GPIO pins information to stdout and blinks activity LED for some time

freebsd-gpio's People

Contributors

gonzoua avatar

Watchers

James Cloos avatar Tomás Pereira Cruz 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.