Skip to content

kmiecikt/numato_gpio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Numato GPIO

Elixir module for communicating with Numato 32-channel GPIO module.

Installation

The package is available in Hex and it can be installed by adding numato_gpio to your list of dependencies in mix.exs:

def deps do
  [
    {:numato_gpio, "~> 0.1.0"}
  ]
end

Usage

The Numato.Gpio module implements all the Numato 32-channel GPIO module commands. It's also a GenServer producer that sends notifications of input GPIO changes.

To start the process, you need to know a virtual COM port name associated with the Numato GPIO device. Assuming it is ttyACM0 on your system, you can run the following:

iex> {:ok, pid} = Numato.Gpio.start_link("ttyACM0")
{:ok, #Reference<...>}

iex> Numato.Gpio.gpio_write(pid, 1, 1)
:ok

iex> Numato.Gpio.gpio_read(pid, 2)
0

To enable notifications, use the gpio_notify_on function:

iex> Numato.Gpio.gpio_notify_on(pid)
:ok

From this point, the module will work as a GenStage producer, with events in format {gpio, new_state}.

API documentation

The ExDoc documentation can be found at at https://hexdocs.pm/numato_gpio.

About

Elixir library for 32-channel Numato GPIO module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages