[−][src]Struct rust_gpiozero::output_devices::Motor
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 tobackward
- 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
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,