b15f-rs/examples/nightrider.rs

21 lines
377 B
Rust
Raw Normal View History

2022-12-17 21:33:33 +00:00
use std::{thread::sleep, time::Duration};
use b15f::b15f::B15F;
2022-12-18 14:19:57 +00:00
fn main() -> Result<(), String> {
let mut drv = B15F::new()?;
2022-12-17 21:33:33 +00:00
let mut position = 0;
let mut direction = 1;
loop {
2022-12-18 14:19:57 +00:00
drv.digital_write::<0>(1 << position)?;
2022-12-17 21:33:33 +00:00
position += direction;
if position >= 7 || position <= 0 {
direction *= -1;
}
2022-12-17 22:03:36 +00:00
sleep(Duration::from_millis(40));
2022-12-17 21:33:33 +00:00
}
}