Using Erlang for GPIO on a Raspberry Pi with https://abyz.me.uk/rpi/pigpio/
Nothing should be running on port 8888, that's where we'll run the pigpio tcp server.
Add the following to your Makefile
DEPS = pigpio
dep_pigpio = git https://github.com/mmalmsten/pigpio.git
Install pigpio on your Raspberry pi
sudo apt-get install pigpio python-pigpio python3-pigpio
Start the pigpio daemon (tcp server)
sudo pigpiod
{ok, Pid} = pigpio:start_link(Gpio_pin)
ok = pigpio:cast(Pid, {command, setmode, 0}).
ok = pigpio:cast(Pid, {read, once}).
ok = pigpio:cast(Pid, {read, N}).
Reply = pigpio:call(Pid, read).
led(Gpio) ->
{ok, Pid} = pigpio:start_link(Gpio),
gen_server:cast(Pid, {command, setmode, 1}),
{ok, Pid}.
{ok, Pid} = led(?GPIO_PIN).
pigpio:cast(Pid, {command, setpullupdown, 1}). % On
pigpio:cast(Pid, {command, setpullupdown, 0}). % Off
button(Gpio) ->
{ok, Pid} = pigpio:start_link(Gpio),
pigpio:cast(Pid, {command, setmode, 0}),
pigpio:cast(Pid, {command, setpullupdown, 2}),
{ok, Pid}.
{ok, Pid} = button(?GPIO_PIN).
Status = pigpio:call(Pid, read).
- Add possibility to add a listener to a pin and update current status in genserver state
- Tests