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

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.

Implementations

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 !RefUnwindSafe for Motor

impl Send for Motor

impl Sync for Motor

impl Unpin for Motor

impl !UnwindSafe for Motor

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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

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

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.