Skip to content

Commit

Permalink
examples: Add led-custom-builder
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Dec 10, 2024
1 parent 77e17cf commit 7407a82
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/led-custom-builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use navigator_rs::{Navigator, UserLed};
use std::thread::sleep;
use std::time::Duration;

use rand::seq::SliceRandom;

fn main() {
let mut nav = Navigator::create().build_navigator_v2_pi5();

let colors = [
[40u8, 0, 0],
[0, 40, 0],
[0, 0, 40],
[40, 40, 0],
[0, 40, 40],
[40, 0, 40],
];

println!("LED show started!");
loop {
nav.set_neopixel(&[*colors.choose(&mut rand::thread_rng()).unwrap()]);
for led in [UserLed::Led1, UserLed::Led2, UserLed::Led3] {
nav.set_led_toggle(led);
sleep(Duration::from_millis(300));
}

println!("{:?}", nav.read_all());
}
}

0 comments on commit 7407a82

Please sign in to comment.