[][src]Struct rust_gpiozero::output_devices::Motor

pub struct Motor { /* fields omitted */ }

Represents a generic motor connected to a bi-directional motor driver circuit (i.e. an H-bridge). Attach an H-bridge motor controller to your Pi; connect a power source (e.g. a battery pack or the 5V pin) to the controller; connect the outputs of the controller board to the two terminals of the motor; connect the inputs of the controller board to two GPIO pins.

Methods

impl Motor[src]

pub fn new(forward_pin: u8, backward_pin: u8) -> Motor[src]

creates a new Motor instance

  • forward_pin - The GPIO pin that the forward input of the motor driver chip is connected to
  • backward - The GPIO pin that the backward input of the motor driver chip is connected to

pub fn forward(&mut self)[src]

Drive the motor forwards at the current speed. You can change the speed using set_speed before calling forward

pub fn backward(&mut self)[src]

Drive the motor backwards. You can change the speed using set_speed before calling backward

pub fn stop(&mut self)[src]

Stop the motor.

pub fn set_speed(&mut self, speed: f64)[src]

The speed at which the motor should turn. Can be any value between 0.0 (stopped) and the default 1.0 (maximum speed)

Auto Trait Implementations

impl Send for Motor

impl Sync for Motor

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.