1

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.

  • since it runs, but fails to stop, it could very well be a programming issue .... please post the actual program that you are using .... add the listing to your question .... use the {} button to format the code listing .... do not post link to code at the project website because it could be copied incorrectly – jsotola Jun 11 at 1:31
  • @jsotola ok, I added the program I ran to my question above although as you can see it is very simple. – thecanmanisback Jun 11 at 1:47
  • Do not use gpio.zero "Robot" class and start with 2 motors. I suggest to try gpioZero "Motor" class and test only 1 motor. – tlfong01 Jun 11 at 4:23
0

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.

  • disregard my last comment, I miscounted GPIO ports before XD but everything is working now, thanks! – thecanmanisback Jun 11 at 13:30
  • How nice to hear the good news! – tlfong01 Jun 11 at 13:47
  • by the way, what is the difference between motor.backward() and motor.reverse? It sounds like they would do the same thing but you use both in your program which works. What is the difference there? – thecanmanisback Jun 11 at 14:06
  • Ha, this shows that you are a lazy guy, doesn't bother to read the friendly manual. Actually when I listed the source code of gz.outputDevices, I found it very long, and worried that lazy guys won't have the patience to read. So I listed a shorter one, gz.motor. So you are wasting my time. How disappointing! :) Anyway, there are only a couple of methods of the Motor class. Perhaps I can list them in my answer. Of course you are also careless, miscounting the pins! Actually I saw your picture showing the pins miscounted by one. :) – tlfong01 Jun 11 at 14:17
  • actually no. There is no manual so I don't know what you are even talking about unless you are talking about the references you listed in which case .reverse is not listed. .reverse() is listed but that is not what your program says. ;) I didn't have a picture? Are you perhaps mixing up my answer with someone elses? Your aggression and the fact that you thought I had a picture both seem to suggest that. – thecanmanisback Jun 11 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.