A quick Google search leads me to How to Control GPIO Hardware from C or C++ | ICS, which tells me that the GPIO pins are simply controlled through the filesystem. Translating the code there gives something like below. Not tested (I have a Pi, but nothing
to connect to the GPIO pins directly ready
).
blink :-
setup_call_cleanup(
open('/sys/class/gpio/export', write, Out1),
write(Out1, 24),
close(Out1)),
setup_call_cleanup(
open('/sys/class/gpio24/direction', write, Out2),
write(Out2, out2),
close(Out2)),
setup_call_cleanup(
open('/sys/class/gpio/gpio24/value', write, Out3),
blink(100, Out3),
close(Out3)).
blink(N, Out) :-
N > 0,
!,
write(Out, 1),
flush_output(Out),
sleep(0.05),
write(Out, 0),
flush_output(Out),
sleep(0.05),
N2 is N - 1,
blink(N2, Out).
blink(_,_).