razshare/zigberrypi
Zig library for interacting with raspberrypi's gpio
Zig library for interacting with raspberrypi's gpio
zigmod aq install 1/tncrazvan/zigberrypi
build.zig
const deps = @import("deps.zig");
// ...
pub fn build(b: *std.Build) void {
// ...
deps.addAllTo(exe);
// ...
}
zigberrypi
in your project withconst gpio = @import("zigberrypi");
Blinking led example
const std = @import("std");
const gpio = @import("zigberrypi");
fn sleepForTwoSeconds() void {
std.time.sleep(std.time.ns_per_s * 2);
}
pub fn main() !void {
var active = false;
const pin11 = try gpio.openWritable(gpio.Pin.PIN11);
defer pin11.close();
while (true) {
try pin11.write(if (active) "1" else "0");
active = !active;
sleepForTwoSeconds();
}
}