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.

tlfong01
  • 4,384
  • 3
  • 9
  • 23
  • 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 '19 at 01: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 '19 at 01: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 '19 at 04:23

1 Answers1

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.

tlfong01
  • 4,384
  • 3
  • 9
  • 23
  • disregard my last comment, I miscounted GPIO ports before XD but everything is working now, thanks! – thecanmanisback Jun 11 '19 at 13:30
  • How nice to hear the good news! – tlfong01 Jun 11 '19 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 '19 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 '19 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 '19 at 14:25
  • Just joking. Manual means the source code. I have summarized in the appendix A. Picture, perhaps I mixed up with other questions, because I am hopping here and there. Perhaps I should check out to restore my confidence of memory. – tlfong01 Jun 11 '19 at 14:30
  • oh I see, so `reverse()` is for the direction of the motor only and `backward()` will actually move the motor backward... so `reverse()` + `forward()` = `backward()`. I understand. and yeah you jump around a lot and answer all the questions smarty, lol don't worry about the joke, I knew that was the issue but you got me! lol anyway thanks again! – thecanmanisback Jun 11 '19 at 14:36
  • Just now I checked the picture I mentioned. It is not in your post, so I mixed up. Sorry to have confused you. By the way, GPIOZero developers are nerdy geeks, so they don't bother to write up any user guide. Source code is their user guide! :( – tlfong01 Jun 11 '19 at 14:36
  • lol yea those programmers are lazy! haha thanks good to know – thecanmanisback Jun 11 '19 at 14:37
  • "reverse() + forward() = backward()" ? Are you sure? I am confused by your equation. I am getting dizzy. Perhaps it is time to call it a day. See you tomorrow. – tlfong01 Jun 11 '19 at 14:40
  • no they are not lazy, lol they made it all work! haha and yes maybe my equation is wrong, forget that I was just trying to make sense of what I had just read. Thanks again and get some sleep. – thecanmanisback Jun 11 '19 at 14:44