Skip to content

JuliaBerry/PiGPIO.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PiGPIO.jl

Control GPIO pins on the Raspberry Pi from Julia

documentation dev

PiGPIO

PiGPIO.jl is a Julia package for the Raspberry which communicates with the pigpio daemon to allow control of the general purpose input outputs (GPIO).

This package is an effective translation of the python package for the same. Which can be found here

Click here for an in-depth tutorial on how you can control GPIO pins such as LEDs from Julia on the Raspberry Pi.

Features

  • OS independent. Only Julia 1.0+ required.
  • Controls one or more Pi's.
  • Hardware timed pulse width modulation.
  • Hardware timed servo pulse.
  • Callbacks when any of GPIO change state.
  • Create and transmit precise waveforms.
  • Read/Write GPIO and set their modes.
  • Wrappers for I2C, SPI, and serial links.

Once a pigpio daemon is launched on the pi this package can connect to it and communicate with it to manipulate the GPIO pins of the pi. The actual work is done by the daemon. One benefit of working this way is that you can remotely access the pi over a network and multiple instances can be connected to the daemon simultaneously.

The daemon process pigpiod

On Raspberry Pi OS, the daemon pigpiod can be installed and launched by using the following shell commands:

# install pigpiod
sudo apt-get install pigpiod
# enable pigpiod via system D
sudo systemctl enable pigpiod
# start pigpiod now
sudo systemctl start pigpiod

The daemon can also be launched manually with sudo pigpiod in the terminal.

Installation and Usage

using Pkg
Pkg.add("PiGPIO")

using PiGPIO

pi=Pi() # connect to the pigpiod daemon on localhost

Example Usage

The pin number corresponds to the GPIO pins (General Purpose Input/Output, aka "BCM" or "Broadcom") and not to the physical pin numbers.

set_mode(pi::Pi, pin::Int, mode)
get_mode(pi::Pi, pin::Int)
# mode can be PiGPIO.INPUT or PiGPIO.OUTPUT

PiGPIO.read(pi, pin)
PiGPIO.write(pi, pin, state)
# state can be PiGPIO.HIGH, PiGPIO.LOW, PiGPIO.ON, PiGPIO.OFF

PiGPIO.set_PWM_dutycycle(pi, pin, dutycyle)
# dutycyle defaults to a range 0-255