11 Jun 2021

Rust and LEDs

After struggling with setting up a Vacuum Florescent Display via I2C for a while I ended up getting about as low level as possible with wires and LEDs to solve the problem. Along the way I needed the most foolproof GPIO level control I could create.

extern crate sysfs_gpio;
use sysfs_gpio::{Direction, Pin};

fn led_fun() {

   let led_sca = Pin::new(475); // number depends on chip, etc.

   let led_sck = Pin::new(474);


fn main() {

After a cargo run you'll need to use sudo to execute the binary i.e. sudo ./target/debug/led-fun-binary to avoid a permission denied error when you attempt to access the GPIO bus.

I really thought I'd hate Rust at first with it's...well, just look at it. It's not pretty. It's damn unpretty - but after a while you can see the elegance in the sparsity.