2

I built a buggy:

https://projects.raspberrypi.org/en/projects/build-a-buggy/2

it seems like it works correctly, except the motor doesn't stop even when I run robby.stop() is there some other command I should use instead?

Program I Ran:

from gpiozero import Robot
robby = Robot(left=(7,8), right=(9,10))

then in the python shell I ran robby.forward() which started the motor.


NOTE: When the board has power the motor goes forward even with the pi turned off.

tlfong01
  • 4,847
  • 3
  • 12
  • 24

1 Answers1

1

Question

gpioZero buggy won't stop! :(

Answer

Update 2019jun22hkt1113

4wd

Try my L298N python program for your buggy! :)

# Driving One Motor Using GpioZeo and L298N v0.01  tlfong01  2019jun11hkt1156
# rpi3B+ python 3.5.3 gpiozero 1.5.0 L298N
# wiring -  

from time import sleep
from gpiozero import Motor

motor = Motor(17, 18)
motor.forward()
sleep(2)
motor.backward()
sleep(2)
motor.reverse
sleep(2)
motor.stop()

gpiozero motor

References

Build a robot buggy - Rpi.org projects

GpioZero Robot

GpioZero Motor

GpioZero Composite Device

GpioZero Device

Source code for gpiozero.output_devices [v1.5.0]

Source Code for gpiozero.motor [v1.2.0]

Choosing Motors - tlfong01 2019mar11

Appendices

Appendix A - Summary of Class motor and its methods

class Motor():

from gpiozero import Motor

motor = Motor(17, 18)

def forward():

Drive the motor forward

def backward():

Drive the motor backward

def reverse():

Reverse the current direction of the motor

def stop():

Stop the motor.

tlfong01
  • 4,847
  • 3
  • 12
  • 24