Go to advanced search

by MrYsLab
Fri Oct 29, 2021 11:12 pm
Forum: Python
Topic: Raspberry 4B and Pololu A4988 not rotating
Replies: 7
Views: 292

Re: Raspberry 4B and Pololu A4988 not rotating

This article has a neice diagram of hooking up an A4988 to an RPi. Hopefully, this helps.
by MrYsLab
Mon Sep 21, 2020 9:36 pm
Forum: Python
Topic: Coding a motor to follow positions in an array using encoders
Replies: 4
Views: 354

Re: Coding a motor to follow positions in an array using encoders

If you need to set a position, check the position, and then do some sort of correction, then a loop would be warranted until the ultimate position is achieved. If you are able to set the position from the current position without having to do a correction, then I would think that a loop is not in or...
by MrYsLab
Sun Sep 20, 2020 10:37 pm
Forum: Python
Topic: Coding a motor to follow positions in an array using encoders
Replies: 4
Views: 354

Re: Coding a motor to follow positions in an array using encoders

I am finding it difficult to visualize what you are trying to accomplish. If I am understanding what you stated, you have 2 arrays. One contains angular positions and the other contains velocities. Reading the encoder gives you the current position of the motor, and again, if I understand what you s...
by MrYsLab
Sun Sep 20, 2020 1:56 pm
Forum: Python
Topic: Thonny Options: Problem with Alternative interpreter or virtual environment
Replies: 5
Views: 1762

Re: Thonny Options: Problem with Alternative interpreter or virtual environment

Did you read this article as suggested above? https://www.techcoil.com/blog/how-to-as ... th-thonny/
It shows how to set the interpreter being used.
by MrYsLab
Wed Sep 09, 2020 4:33 pm
Forum: Python
Topic: Catching a Ctrl-C
Replies: 7
Views: 989

Re: Catching a Ctrl-C

It would be most helpful if you posted your code. But in the meantime, here is what I normally do if I am trapping a signal from Control-c do_some_stuff(): try: to_do_it() except KeyboardInterrupt: perform_a_graceful_exit() def signal_handler(sig, frame): print('Exiting Through Signal Handler') rais...
by MrYsLab
Fri Sep 04, 2020 8:02 pm
Forum: Python
Topic: LED Bar Graph (tkinter Display on Screen)
Replies: 12
Views: 1021

Re: LED Bar Graph (tkinter Display on Screen)

The problem is the calls to sleep. Sleep will block Tkinter's main loop. If you remove the sleep calls the problem should go away. If you really need to add the calls to sleep, either consider using a thread to do so or use the Tkinter "after" method. https://riptutorial.com/tkinter/exampl...
by MrYsLab
Sun Aug 30, 2020 4:14 pm
Forum: Python
Topic: Serial USB port identification
Replies: 4
Views: 438

Re: Serial USB port identification

I am not sure if this will solve your problem or not, but pyserial comes with a utility to list the ports and their details. The command-line incantation of this is shown below. If you incorporate the utility into your program you can get more detail. This link descirbes all that the utility returns...
by MrYsLab
Thu Jul 23, 2020 6:14 pm
Forum: Python
Topic: Relay Timer
Replies: 2
Views: 443

Re: Relay Timer

My suggestion would be to use gpiozero. https://gpiozero.readthedocs.io/en/stable/index.html Here is a recipe for monitoring a button: https://gpiozero.readthedocs.io/en/stable/api_input.html#button For the relay, you can use gpiozero's recipe to control an LED: https://gpiozero.readthedocs.io/en/st...
by MrYsLab
Sun Jul 12, 2020 6:06 pm
Forum: Python
Topic: check if exist a file
Replies: 7
Views: 626

Re: check if exist a file

This article should solve your issue: https://dbader.org/blog/python-check-if-file-exists
by MrYsLab
Tue Jul 07, 2020 7:51 pm
Forum: Python
Topic: How sub thread change widget in main thread
Replies: 7
Views: 699

Re: How sub thread change widget in main thread

It is not clear why you need to spawn a thread, but here is something that appears to work: from guizero import App, ButtonGroup, Box, Text, TextBox, PushButton import cv2 import time as tm from datetime import * import threading def doit(): start_video_button.enable() #NOT WORKING I GET AN ERROR ME...
by MrYsLab
Tue Jul 07, 2020 12:22 pm
Forum: Python
Topic: How sub thread change widget in main thread
Replies: 7
Views: 699

Re: How sub thread change widget in main thread

Could you please post the rest of your code? It is not clear from the snippet if the button is a physical button connected to GPIO or a GUI button. If it is a GUI button, without knowing which GUI library your using or the code you developed, it is difficult (at least for me) to provide any guidance.
by MrYsLab
Sun Jul 05, 2020 2:29 pm
Forum: Python
Topic: Asteroids Infinity Game - Error message
Replies: 12
Views: 662

Re: Asteroids Infinity Game - Error message

The not equal operator for Python is != and not <>.
Also, you do not need to check for None. You can do the following:

Code: Select all

if Pygame.mixer.get_init():
	# whatever follows
by MrYsLab
Sat Jul 04, 2020 10:43 pm
Forum: Python
Topic: LEDBoard.blink
Replies: 1
Views: 242

Re: LEDBoard.blink

The leds variable contains an LEDBoard which is a collection of LEDs. No matter what you set "value" to, for the LEDBoard, when you call blink, it blinks everything in the collection. If you want to blink single LEDs in the collection, you can access and blink any LED by using its index in...
by MrYsLab
Wed Jul 01, 2020 3:22 pm
Forum: Python
Topic: Align Left function not working
Replies: 3
Views: 379

Re: Align Left function not working

Does this do what you are trying to do? from guizero import App, Text, Box, TextBox, ButtonGroup app = App(layout="grid", title="Hello world") #box 2 box2 = Box(app, border=True, grid=[0,0], align='left') text2 = Text(box2, text="Photo",size=20, font="Times new rom...
by MrYsLab
Sat Jun 27, 2020 2:46 pm
Forum: Python
Topic: Python 3.6 -m venv failed.
Replies: 5
Views: 1221

Re: Python 3.6 -m venv failed.

I find using pyenv to manage and create virtual environments for various Python versions is the way to go. Take a look at this article for installing and its use. https://realpython.com/intro-to-pyenv/
I
by MrYsLab
Mon Jun 22, 2020 9:23 pm
Forum: Python
Topic: Ticker interrupt in Python?
Replies: 7
Views: 674

Re: Ticker interrupt in Python?

There are many ways to solve this problem. Here is one of those ways (there may be better alternatives) import threading import time from datetime import timedelta WAIT_TIME_SECONDS = 1 class MyStuff(threading.Thread): def __init__(self, interval): threading.Thread.__init__(self) self.daemon = False...
by MrYsLab
Mon Jun 22, 2020 1:22 pm
Forum: Python
Topic: Ticker interrupt in Python?
Replies: 7
Views: 674

Re: Ticker interrupt in Python?

Python has timing capabilities, but cannot guarantee the precision of that timing. Here is an article that addresses the precision of using Python for timing events. https://stackoverflow.com/questions/1938048/high-precision-clock-in-python . If you need precision timing you might try pipgpio http:/...
by MrYsLab
Tue Jun 09, 2020 6:25 pm
Forum: Python
Topic: RPi4 Python code showing high CPU load with 7" LCD
Replies: 2
Views: 425

Re: RPi4 Python code showing high CPU load with 7" LCD

Sounds like you can use a profiler. Check out this article: https://uwekorn.com/2018/10/05/pyflame.html. Scroll down to the heading "My other favorite profilers" and there is a discussion of using the line profiler to help pinpoint the problem on a line basis.
by MrYsLab
Tue Jun 09, 2020 3:44 am
Forum: Python
Topic: Python program to see if background process is running
Replies: 5
Views: 475

Re: Python program to see if background process is running

Here is a working example of where I check to see if a process named 'backplane' is currently running: https://github.com/MrYsLab/s3-extend/bl ... 3a.py#L161
by MrYsLab
Tue Jun 09, 2020 1:26 am
Forum: Python
Topic: Python program to see if background process is running
Replies: 5
Views: 475

Re: Python program to see if background process is running

Take a look at psutil. Their docs show an example of how to find a process by name https://psutil.readthedocs.io/en/latest ... ss-by-name. It is an extremely useful library.
by MrYsLab
Sat Jun 06, 2020 11:32 pm
Forum: Python
Topic: Errors while connecting 2 pi as server & client
Replies: 8
Views: 716

Re: Errors while connecting 2 pi as server & client

I am not sure what your code looks like at the moment. The following code works. Compare it with your current code to see what might be your problem. server.py import socket import sys # Create a TCP/IP socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket to the port ser...
by MrYsLab
Thu Jun 04, 2020 4:05 pm
Forum: Python
Topic: Errors while connecting 2 pi as server & client
Replies: 8
Views: 716

Re: Errors while connecting 2 pi as server & client

Change

Code: Select all

data = conn.recv(1024)
to

Code: Select all

data = conn.recv(1024).decode()
by MrYsLab
Mon May 25, 2020 10:38 pm
Forum: Python
Topic: How to make a "start and stop" Button?
Replies: 1
Views: 297

Re: How to make a "start and stop" Button?

I don't fully understand your code logic, so I am placing some code below that does what I think you want. The color scheme and fonts probably need to be changed to your liking. Also, you have a loop that is trying to open up 10 recording sessions. I am not familiar with picamera so I am not sure if...
by MrYsLab
Mon May 25, 2020 1:19 pm
Forum: Python
Topic: How do I create popup window with countdown timer (Python kivy)
Replies: 3
Views: 838

Re: How do I create popup window with countdown timer (Python kivy)

Look at the code on this page. This should give you enough information on changing text between windows.
https://stackoverflow.com/questions/611 ... rent-popup
by MrYsLab
Sat May 23, 2020 3:29 pm
Forum: Python
Topic: How do I create popup window with countdown timer (Python kivy)
Replies: 3
Views: 838

Re: How do I create popup window with countdown timer (Python kivy)

I found this example that is running in the main window. You should be able to port this code to the pop up and have it do something similar. https://stackoverflow.com/questions/41937173/kivy-simple-countdown-minute-and-second-timer main.py from kivy.app import App from kivy.uix.label import Label f...

Go to advanced search