GrovePi v0.6.1 GrovePi.Digital View Source

Write to and read digital I/O on the GrovePi. This module provides a low level API to digital sensors.

Example usage:

iex> pin = 3

iex> GrovePi.Digital.set_pin_mode(pin, :input)
:ok
iex> GrovePi.Digital.read(pin, 0)
1
iex> GrovePi.Digital.set_pin_mode(pin, :output)
:ok
iex> GrovePi.Digital.write(pin, 1)
:ok
iex> GrovePi.Digital.write(pin, 0)
:ok

Link to this section Summary

Functions

Read the value on a digital I/O pin. Before this is called, the pin must be configured as an :input with set_pin_mode/2 or set_pin_mode/3

Configure a digital I/O pin to be an :input or an :output

Write a value on a digital I/O pin. Before this is called, the pin must be configured as an :output with set_pin_mode/2 or set_pin_mode/3. Valid values are 0 (low) and 1 (high)

Link to this section Types

Link to this type level() View Source
level() :: 0 | 1
Link to this type pin_mode() View Source
pin_mode() :: :input | :output

Link to this section Functions

Link to this function read(pin) View Source
read(GrovePi.pin()) :: level() | {:error, term()}

Read the value on a digital I/O pin. Before this is called, the pin must be configured as an :input with set_pin_mode/2 or set_pin_mode/3.

Link to this function read(prefix, pin) View Source
read(atom(), GrovePi.pin()) :: level() | {:error, term()}
Link to this function set_pin_mode(pin, pin_mode) View Source
set_pin_mode(GrovePi.pin(), pin_mode()) :: :ok | {:error, term()}

Configure a digital I/O pin to be an :input or an :output.

Link to this function set_pin_mode(prefix, pin, pin_mode) View Source
set_pin_mode(atom(), GrovePi.pin(), pin_mode()) :: :ok | {:error, term()}
Link to this function write(pin, value) View Source
write(GrovePi.pin(), level()) :: :ok | {:error, term()}

Write a value on a digital I/O pin. Before this is called, the pin must be configured as an :output with set_pin_mode/2 or set_pin_mode/3. Valid values are 0 (low) and 1 (high).

Link to this function write(prefix, pin, value) View Source
write(atom(), GrovePi.pin(), level()) :: :ok | {:error, term()}