Go to advanced search

by ben_nuttall
Tue Mar 14, 2017 12:13 am
Forum: Automation, sensing and robotics
Topic: Raspberry Pi-der Obstacle avoidance with gpiozero
Replies: 35
Views: 5659

Re: Raspberry Pi-der Obstacle avoidance with gpiozero

front.when_in_range = gobackward while True: goforward() This code will not work like you think. The while loop means it constantly repeats "goforward()". The in_range event does not override this. Something like this might work better: front.when_in_range = gobackward front.when_out_of_range = gof...
by ben_nuttall
Mon Mar 13, 2017 10:17 pm
Forum: Automation, sensing and robotics
Topic: Raspberry Pi-der Obstacle avoidance with gpiozero
Replies: 35
Views: 5659

Re: Raspberry Pi-der Obstacle avoidance with gpiozero

I saw the Robot class and the CamJamEdukit but the Pi-der can't use those as each motor has to 'take turns', if they both run at once the legs kind of 'cancel each other out' or work against each other. I have learnt this through playing about with it in scratch and have found the optimal forward l...
by ben_nuttall
Mon Mar 13, 2017 8:19 pm
Forum: Automation, sensing and robotics
Topic: Raspberry Pi-der Obstacle avoidance with gpiozero
Replies: 35
Views: 5659

Re: Raspberry Pi-der Obstacle avoidance with gpiozero

A few comments: - gpiozero has no need for "GPIO.cleanup()" as it does it automatically when the script ends (and this won't do anything because there's no "GPIO" in scope). - Incidentally, this means that when you're not using a while loop to keep a program running (say, using event callbacks), you...
by ben_nuttall
Fri Mar 10, 2017 2:56 pm
Forum: Raspbian
Topic: Auto starting pigpio from raspi-config
Replies: 1
Views: 1237

Re: Auto starting pigpio from raspi-config

The option in raspi-config/rcgui does not run the pigpio daemon. It just allows remote connections when the daemon is running.
by ben_nuttall
Mon Mar 06, 2017 11:11 am
Forum: Python
Topic: Problem Using LED's With Buttons
Replies: 5
Views: 1053

Re: Problem Using LED's With Buttons

Try: from gpiozero import LED, Button led = LED(6) button = Button(13) while True: if button.is_pressed: led.on() else: led.off() Read up more at http://gpiozero.readthedocs.io and follow a learning resource at https://www.raspberrypi.org/learning/physical-computing-with-python/
by ben_nuttall
Sun Mar 05, 2017 10:37 am
Forum: Python
Topic: Is pip currently broken in Debain/Raspbian Jessie?
Replies: 8
Views: 4398

Re: Is pip currently broken in Debain/Raspbian Jessie?

Awesome. Thanks Dave. I've had issues with dependency installation before, but only in odd cases. I regularly install ipython with pip on a new Raspbian image and it's never been a problem until now. Like you say, must be a new dependency issue. I'm not sure there's anything we can do about fixing i...
by ben_nuttall
Fri Mar 03, 2017 1:51 pm
Forum: Python
Topic: Is pip currently broken in Debain/Raspbian Jessie?
Replies: 8
Views: 4398

Re: Is pip currently broken in Debain/Raspbian Jessie?

Yes. That fixes it, but it's equivalent to getting pip to update itself.

The problem is that it seems the pip that ships with Raspbian is broken.
by ben_nuttall
Fri Mar 03, 2017 1:25 pm
Forum: Python
Topic: Is pip currently broken in Debain/Raspbian Jessie?
Replies: 8
Views: 4398

Is pip currently broken in Debain/Raspbian Jessie?

I've been having issues with pip the last few days. I don't know what's causing it. (Note all following examples refer to "pip", but I'm referring to both "pip" for Python 2 and "pip3" for Python 3) The apt version of pip in Debian/Raspbian Jessie is 1.5.6 and in Stretch (the next Debian release) is...
by ben_nuttall
Thu Feb 16, 2017 3:57 pm
Forum: Python
Topic: Code question
Replies: 3
Views: 846

Re: Code question

You need to keep the object alive for its state to be maintained. The whole point of having an object is that you create it, then manipulate it, read it, write to it, change its state. If you keep recreating the object inside a loop, you don't maintain state, you throw it away each time and start ag...
by ben_nuttall
Tue Feb 07, 2017 6:57 pm
Forum: Automation, sensing and robotics
Topic: Stepper Motor Help
Replies: 10
Views: 2165

Re: Stepper Motor Help

Thanks for the help, I got my stepper working with gpiozero. Now, what type of motor are they using in this resource: https://www.raspberrypi.org/learning/physical-computing-with-python/motors/ If anyone has a link to a specific recommended model I could purchase, that would be great. The motors us...
by ben_nuttall
Mon Feb 06, 2017 11:08 pm
Forum: Automation, sensing and robotics
Topic: Stepper Motor Help
Replies: 10
Views: 2165

Re: Stepper Motor Help

No stepper motor class in gpiozero yet - but it's been suggested - and I believe people are using OutputDevice with some success.

See https://github.com/RPi-Distro/python-gp ... issues/144 and https://github.com/topshed/PiClubSushi/ ... erBETA.pdf
by ben_nuttall
Tue Jan 31, 2017 11:53 am
Forum: Python
Topic: GPIO Zero called functions puzzel
Replies: 2
Views: 773

Re: GPIO Zero called functions puzzel

gpiozero Button has a held_time property:

Code: Select all

>>> from gpiozero import Button
>>> b = Button(2)
>>> b.held_time
4.0158562660217285
>>> b.held_time
5.168334722518921
Also see the when_held event handler property. Read more at http://gpiozero.readthedocs.io/en/v1.3. ... tml#button
by ben_nuttall
Sun Jan 29, 2017 9:10 pm
Forum: Python
Topic: need to loop a program!
Replies: 12
Views: 2107

Re: need to loop a program!

I have the program working in the background when the pi comes on using sudo nano /etc/rc.local it switches the pump on and off correctly but does not write a timestamp to file as expected. does it need to write a different file . this is the finished script. You need to reference your logfile abso...
by ben_nuttall
Mon Jan 23, 2017 8:31 pm
Forum: General discussion
Topic: Gpio Zero Library and Eclipse Compatiblity
Replies: 3
Views: 1245

Re: Gpio Zero Library and Eclipse Compatiblity

Great! Are you using remote pins?
by ben_nuttall
Mon Jan 09, 2017 12:21 pm
Forum: Python
Topic: Does gpiozero support ADC PCF8591
Replies: 2
Views: 736

Re: Does gpiozero support ADC PCF8591

FYI your best bet is to look at the gpiozero docs to see what we support: http://gpiozero.readthedocs.io
by ben_nuttall
Mon Jan 09, 2017 12:20 pm
Forum: Python
Topic: Does gpiozero support ADC PCF8591
Replies: 2
Views: 736

Re: Does gpiozero support ADC PCF8591

gpiozero does not currently support this particular ADC. It's I2C and we don't have any I2C support at the moment - maybe a future release will introduce this chip.

We support the range of SPI-based MCP* chips which work really nicely in gpiozero.
by ben_nuttall
Wed Jan 04, 2017 8:25 pm
Forum: Automation, sensing and robotics
Topic: HC-SR04 Range Issues
Replies: 25
Views: 4363

Re: HC-SR04 Range Issues

Yep - max_distance is 1m by default. Change it with:

Code: Select all

sensor = DistanceSensor(echo, trigger, max_distance=5)
or similar.

See the docs
by ben_nuttall
Mon Jan 02, 2017 6:51 pm
Forum: Beginners
Topic: sample code buggy?
Replies: 24
Views: 3243

Re: sample code buggy?

wow, really? So why, if their code is all going to require python3, would they release raspian without it installed? Doing an apt-get install python3 now, it wasn't installed. Crossing my fingers. Python 3 is installed by default in Raspbian. It's not in Jessie Lite. We don't recommend Jessie Lite ...
by ben_nuttall
Wed Dec 28, 2016 6:44 pm
Forum: Python
Topic: GPIOZero issue
Replies: 2
Views: 851

Re: GPIOZero issue

Please post the code!
by ben_nuttall
Wed Sep 28, 2016 12:10 am
Forum: General discussion
Topic: Error in my flashing LED code.
Replies: 2
Views: 634

Re: Error in my flashing LED code.

It sounds like you may have a very old SD card image. Try grabbing a recent image from the Raspberry Pi downloads page: https://www.raspberrypi.org/downloads/raspbian/ The old OS image required sudo (super user permissions) to control the GPIO pins. The newer ones allow the regular user to do so. An...
by ben_nuttall
Wed Sep 28, 2016 12:07 am
Forum: Beginners
Topic: what is remote GPIO
Replies: 18
Views: 38505

Re: what is remote GPIO

Both answers correct. It was added to allow remote access to gpio pins from another Pi on the network, using the pigpio daemon, as this is possible using the Python library gpiozero. See Marc's link above, and my blog post which covers it in more detail: http://bennuttall.com/whats-new-gpio-zero-v1-3/
by ben_nuttall
Wed Sep 28, 2016 12:05 am
Forum: Beginners
Topic: Is it possible to connect switches and a timer ?
Replies: 5
Views: 961

Re: Is it possible to connect switches and a timer ?

GPIO Zero is the easiest way of doing something when buttons are pressed. See examples: http://gpiozero.readthedocs.io/en/v1.3.1/recipes.html#button The best place to start is https://www.raspberrypi.org/learning/physical-computing-with-python/ Just open Python 3 from the main menu in Raspbian and t...
by ben_nuttall
Tue Sep 27, 2016 10:46 pm
Forum: Beginners
Topic: Building a timelapse setup with PiCamera
Replies: 6
Views: 1315

Re: Building a timelapse setup with PiCamera

I see you import the RPi.GPIO module but don't seem to use it in your code. Do you intend to? I would move and use picamera for doing the timelapse https://picamera.readthedocs.io/en/rele ... -sequences Yes - I highly recommend picamera. Pure Python, no os.system calls - it just works, and works bri...
by ben_nuttall
Tue Sep 27, 2016 10:28 pm
Forum: Python
Topic: GpioZero code to PiGpio - lightgate
Replies: 2
Views: 694

Re: GpioZero code to PiGpio - lightgate

You can use pigpio as the back-end for gpiozero, and use it remotely. That sounds like exactly what you want to do, and will save you rewriting the code.

See http://gpiozero.readthedocs.io/en/v1.3. ... #pigpiopin and http://bennuttall.com/whats-new-gpio-zero-v1-3/
by ben_nuttall
Fri Jul 01, 2016 7:59 pm
Forum: Beginners
Topic: Can't use GPIO
Replies: 2
Views: 482

Re: Can't use GPIO

from gpiozero import LED light = LED(24) light.on You've used light.on which should be light.on() . You're not running the function, you're just saying its name. Though "when it gets to the second line it just throws up a massive screed of error messages" doesn't make sense in this situation. Can y...

Go to advanced search