Hi @archnim
I use my package wiringPiNim. There are some small examples in the README. I know there are other RPi packages, but I can't find them on https://nimble.directory.
import wiringPiNim
if piSetup() >= 0:
piPinModeOutput(24)
piDigitalWrite(24, 1)
piDigitalRead(24)
I did something like this
nim
proc hardReset*(pin: int) =
writeFile("/sys/class/gpio/export", $pin)
writeFile(fmt"/sys/class/gpio/gpio{pin}/direction", "out")
writeFile(fmt"/sys/class/gpio/gpio{pin}/value", "0")
sleep 100
writeFile(fmt"/sys/class/gpio/gpio{pin}/value", "1")
sleep 100
writeFile(fmt"/sys/class/gpio/gpio{pin}/value", "0")
sleep 100
writeFile("/sys/class/gpio/unexport", $pin)
sleep 100
And, just for what it's worth, if you didn't know where to start, you could just have used c2nim on wiringPi.h (now installed by default on Raspian) and you would have gotten this: https://github.com/aboisvert/thermopi/blob/master/server/src/thermopipkg/wiringPi.nim which worked great for me, interfacing directly to wiringpi's API.
Nim's C interop is great and in many cases you can use c2nim's output unchanged.