Go to advanced search

by MrYsLab
Fri May 31, 2019 4:01 pm
Forum: Python
Topic: Seeking assistance getting tKinter to play nice
Replies: 7
Views: 320

Re: Seeking assistance getting tKinter to play nice

I don't have a definitive answer for you, but the fact that the program is constantly playing with "after" in addition to being mixed with asynchronous events, looks somewhat suspicious. Perhaps, you need to provide a lock around the after calls that would prevent one call from clobbering another. I...
by MrYsLab
Wed May 29, 2019 9:04 pm
Forum: Python
Topic: Using 7 segment display inside Python code
Replies: 8
Views: 1256

Re: Using 7 segment display inside Python code

It appears you did not install the library properly. You can find detailed install instructions here: https://luma-led-matrix.readthedocs.io/en/latest/
by MrYsLab
Thu May 16, 2019 11:07 pm
Forum: Python
Topic: How to run a servo motor if a particular condition is satisfied
Replies: 15
Views: 582

Re: How to run a servo motor if a particular condition is satisfied

If you correct your code on Github and provide a link, I can take a look. You may also want to run your code through a PEP-8 (linter) tool that will point out where your code does not conform to the PEP8 standards - http://pep8online.com/
by MrYsLab
Tue May 14, 2019 6:35 pm
Forum: Python
Topic: How to run a servo motor if a particular condition is satisfied
Replies: 15
Views: 582

Re: How to run a servo motor if a particular condition is satisfied

Most likely. Put a breakpoint where the PWM mode is being set, and see if it occurs more than once, that is how you are getting the error.
by MrYsLab
Mon May 13, 2019 1:44 pm
Forum: Python
Topic: Retrieving counts from an [Absolute Rotary Encoder]
Replies: 3
Views: 207

Re: Retrieving counts from an [Absolute Rotary Encoder]

I don't have any experience with this encoder, but I did find a Git repository that handles it for the Arduino. https://github.com/heavydetail/EMS22A_Arduino Hopefully it should give you some ideas about how to control the device, but of course you will need to port the C++ to Python. You might want...
by MrYsLab
Mon May 13, 2019 1:22 pm
Forum: Python
Topic: How to run a servo motor if a particular condition is satisfied
Replies: 15
Views: 582

Re: How to run a servo motor if a particular condition is satisfied

The camera2.py script has several other errors in addition to the indentation issues that need to be addressed. In addition,the code possesses no cohesive structure, making it difficult to read and debug. Here are my suggestions: 1. Take a look at this article https://dbader.org/blog/how-to-structur...
by MrYsLab
Mon May 13, 2019 1:55 am
Forum: Python
Topic: How to run a servo motor if a particular condition is satisfied
Replies: 15
Views: 582

Re: How to run a servo motor if a particular condition is satisfied

The indentation is not correct, and when I run the file through PyCharm inspection there are 4 errors after I fixed the indentation. The move function should probably be moved to the top of your file and the GPIO.cleanup should probably be delayed until the end of your program.
by MrYsLab
Sun May 12, 2019 11:22 pm
Forum: Python
Topic: Hall-Effect Sensor pulse input limits with Python
Replies: 5
Views: 275

Re: Hall-Effect Sensor pulse input limits with Python

I totally agree with Joan - never argue with genius! (Joan, not me). Take a look at https://github.com/MrYsLab/razmq/blob/master/razmq/encoders/encoders_pigpio.py . I built a class a while ago that might just do what you want. It uses an early version of the python-banyan framework https://mryslab.g...
by MrYsLab
Sun May 12, 2019 8:47 pm
Forum: Python
Topic: How to run a servo motor if a particular condition is satisfied
Replies: 15
Views: 582

Re: How to run a servo motor if a particular condition is satisfied

I just ran the following code on my RPi. import time import RPi.GPIO as GPIO def move_servo(p): p.start(2.5) # Initialization try: p.ChangeDutyCycle(5) time.sleep(4) p.ChangeDutyCycle(10) time.sleep(4) except KeyboardInterrupt: p.stop() servoPIN = 17 GPIO.setmode(GPIO.BCM) GPIO.setup(servoPIN, GPIO....
by MrYsLab
Sun May 12, 2019 8:17 pm
Forum: Python
Topic: How to run a servo motor if a particular condition is satisfied
Replies: 15
Views: 582

Re: How to run a servo motor if a particular condition is satisfied

I reordered your code somewhat. Having the function defined within the loop created a new PWM instance with each iteratation. import time def move_servo(p): p.start(2.5) # Initialization try: p.ChangeDutyCycle(5) time.sleep(4) p.ChangeDutyCycle(10) time.sleep(4) except KeyboardInterrupt: p.stop() se...
by MrYsLab
Sun May 12, 2019 7:21 pm
Forum: Python
Topic: How to run a servo motor if a particular condition is satisfied
Replies: 15
Views: 582

Re: How to run a servo motor if a particular condition is satisfied

The PWM object, in your case p p = GPIO.PWM(servoPIN, 50) # GPIO 17 for PWM with 50Hz Should be established outside of the loop - it should only be done once. If that is what you are doing, perhaps if you provide the code that includes the servo integration in the camera, that might help for others ...
by MrYsLab
Sun May 12, 2019 6:55 pm
Forum: Python
Topic: How to run a servo motor if a particular condition is satisfied
Replies: 15
Views: 582

Re: How to run a servo motor if a particular condition is satisfied

You could add a function to your code to do the servo moves. Instead of a function, I prefer to do things within a class - avoids the whole global rabbit hole. Below is a sample of what I mean (not tested). If you don't want to use the class, just initialize the servo pin somewhere in your camera co...
by MrYsLab
Sun May 12, 2019 2:57 pm
Forum: Python
Topic: Python rfid media player script woes
Replies: 2
Views: 186

Re: Python rfid media player script woes

There is a package called python-vlc that you can use. https://pypi.org/project/python-vlc/ I just ran this script to play an .mp3 and it works for me import vlc import time player = vlc.MediaPlayer("/home/Music/01. All Souls Night.mp3") player.play() while True: time.sleep(.1) The music plays fine,...
by MrYsLab
Wed May 08, 2019 9:11 pm
Forum: Python
Topic: Distance sensor does not work after introducing the keypress function
Replies: 2
Views: 182

Re: Distance sensor does not work after introducing the keypress function

Please don't take this the wrong way, but your code is a bit of a mess. You are initializing the GPIO within a while loop as well as defining functions within that loop. You probably want to do all the GPIO initialization in your init function and just break out all the defs out of the loop. You sho...
by MrYsLab
Wed May 08, 2019 6:02 pm
Forum: Python
Topic: Bittrex API and Python
Replies: 2
Views: 209

Re: Bittrex API and Python

You have a typo in your code : my_bittrex = Bittrex("apikey", "secretkey, api_version="API_V1_1") should be: my_bittrex = Bittrex("apikey", "secretkey", api_version="API_V1_1") Not a big deal, but just thought I would point that out. Now on to your question. When your code executes: with my_bittrex....
by MrYsLab
Wed May 08, 2019 5:09 pm
Forum: Python
Topic: Rpi read status from alarm
Replies: 1
Views: 122

Re: Rpi read status from alarm

There are several ways of doing this, but I prefer to use a package called apscheduler. The background scheduler feature works well for me https://apscheduler.readthedocs.io/en/latest/userguide.html?highlight=backgroundscheduler What you could do is to have your sensor use a callback that when the s...
by MrYsLab
Mon May 06, 2019 1:49 pm
Forum: Python
Topic: Interrupts not behaving as expected
Replies: 5
Views: 336

Re: Interrupts not behaving as expected

The reason I do not add the pull-downs is because the circuity I am using does not require it. What I would suggest you do is first make sure that your button code works. You can use the code I provided, just change the pull-down and pin numbers. If that works, then add the things that I left out, o...
by MrYsLab
Mon May 06, 2019 12:05 am
Forum: Python
Topic: Newbie problem.. tryinng to use GPIOZero routines to interface a DS18b20 sensor.
Replies: 7
Views: 313

Re: Newbie problem..

I may be wrong here, but I don't think Gpiozero provides an interface to the DS18b20. If you are willing to try pigpio http://abyz.me.uk/rpi/pigpio/index.html , you could the example code for that device: http://abyz.me.uk/rpi/pigpio/code/DS18B20-1_py.zip You can use pigpio with Gpiozero https://gpi...
by MrYsLab
Sun May 05, 2019 11:48 pm
Forum: Python
Topic: How to fix "attributeerror: type object 'rpi.gpio.pwm' has no attribute 'servo' "?
Replies: 1
Views: 136

Re: How to fix "attributeerror: type object 'rpi.gpio.pwm' has no attribute 'servo' "?

I don't think the following line of code is valid: servo = PWM.Servo() If I check to see what attributes are available in RPi.GPIO PWM, here is what I see: >>> from Rpi.GPIO import PWM >>> dir(PWM) ['ChangeDutyCycle', 'ChangeFrequency', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__...
by MrYsLab
Sun May 05, 2019 2:24 pm
Forum: Python
Topic: Interrupts not behaving as expected
Replies: 5
Views: 336

Re: Interrupts not behaving as expected

I have modified your program to run using python3 and to match my hardware. When I run this, it runs as expected. Make sure that you have things wired correctly. #!/usr/bin/python3 from tkinter import * import RPi.GPIO as GPIO import time # import escapeFunctions GPIO.setmode(GPIO.BCM) # GPIO.cleanu...
by MrYsLab
Sun May 05, 2019 2:00 pm
Forum: Python
Topic: One Button Code Lock
Replies: 3
Views: 212

Re: One Button Code Lock

If you absolutely have to a single button used to input the code, then as you say, the synchronization of human to computer timing is difficult. Perhaps, you could provide an LED that lights to tell the user when to enter the next press. If there is no press between flashes, then the input is consid...
by MrYsLab
Sat May 04, 2019 10:22 pm
Forum: Python
Topic: Bluepy on Raspbian
Replies: 1
Views: 148

Re: Bluepy on Raspbian

Try this:

Code: Select all

from bluepy.btle import Peripheral
by MrYsLab
Sat May 04, 2019 10:00 pm
Forum: Python
Topic: Play sounds using MIDI Keyboard
Replies: 1
Views: 118

Re: Play sounds using MIDI Keyboard

You've not given much information on what you tried and what didn't work for you, but doing some quick googling, I found the following 2 articles that may help. https://howchoo.com/g/zmm2zdi3ody/raspberry-pi-midi-keyboard-synthesizer https://medium.com/@rreinold/how-to-use-a-raspberry-pi-3-to-turn-m...
by MrYsLab
Fri May 03, 2019 11:35 pm
Forum: Python
Topic: PySerial: Does "write_timeout" actually do anything?
Replies: 2
Views: 196

Re: PySerial: Does "write_timeout" actually do anything?

The write timeout also takes into account the write buffer size. Here is a simple test program I wrote: import serial b = bytearray() for c in range(0, 64): b += str(5).encode() print(b) ser = serial.Serial(port='/dev/ttyACM0', baudrate=9600, timeout=1, write_timeout=0.01) written = ser.write(b) pri...

Go to advanced search