Julia is a free and open-source general purpose programming language made specifically for scientific computing.
In this blog I wanted to document my Pi Julia interface testing.
Julia is supported on Windows, MacOS and Linux. See the download documentation for your specific system at : https://julialang.org/downloads/. To install Julia on a Raspberry Pi enter:
sudo apt install julia
To check your install, you can run Julia at the command line:
pi@raspberrypi:~ $ julia _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 1.0.3 _/ |\__'_|_|_|\__'_| | Raspbian ⛬ julia/1.0.3+dfsg-4+rpi1 |__/ | julia>
Julia packages can be installed at the command line by:
julia> using Pkg julia> Pkg.add("some package")
Julia with Raspberry Pi GPIO
A Raspberry Pi package “PiGPIO” is installed by:
julia> using Pkg julia> Pkg.add("PiGPIO")
Once the package is installed a daemon ( pigpiod) is created that the Julia script connects to. The pigpiod daemon is started by:
Below is an example script that cycles a GPIO pin. For this example the GPIO pin is passed as a keyboard input. The readline() method returns a string, so parse() is used get an integer.
To run the code enter:
pi@raspberrypi:~ $ julia pi1.jl Enter the GPIO pin: 4 Pin used: 4 [ Info: Successfully connected! Julia is cycling an LED 5 times Cleaning up!
Raspberry Pi Inputs
A simple GPIO read input programs is:
The output will look something like:
pi@raspberrypi: $ julia pi2.jl [ Info: Successfully connected! Input status on Pin 23... hit Cntl-C to break out 1 1 0 0
As a Python user l found using Julia to be frustrating, the documentation is weak and there aren’t the extensive libraries that I’m used to using in Python.