| Crates.io | rcx |
| lib.rs | rcx |
| version | 0.1.3 |
| created_at | 2024-01-07 21:26:50.89973+00 |
| updated_at | 2024-02-25 15:38:31.248382+00 |
| description | Communicate with LEGO RCX bricks |
| homepage | |
| repository | https://github.com/bricks-rs/rcx |
| max_upload_size | |
| id | 1092038 |
| size | 113,568 |
Interface library for communicating with the LEGO Mindstorms RCX brick
use rcx::{tower::usb::UsbTower, MotorSelection, Rcx};
const DEVICE: &str = "/dev/usb/legousbtower0";
fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
let rcx = UsbTower::open(DEVICE)?;
let mut rcx = Rcx::new(rcx);
rcx.set_motor_direction(MotorSelection::A, rcx::MotorDirection::Forward)?;
rcx.set_motor_power(MotorSelection::A, 5)?;
rcx.set_motor_on_off(MotorSelection::A, rcx::MotorPowerState::On)?;
std::thread::sleep(std::time::Duration::from_secs(2));
rcx.set_motor_on_off(MotorSelection::A, rcx::MotorPowerState::Float)?;
Ok(())
}