Go to advanced search

by MrYsLab
Sun Sep 23, 2018 8:18 am
Forum: Python
Topic: GPIO Detect Circuit open or Closed
Replies: 4
Views: 1538

Re: GPIO Detect Circuit open or Closed

You need to remember the state when a state change occurs and compare the current state to that value. Here is a non-hardware dependent proof of concept that continuously checks but the state changes only once per second: import time import sys class StateChecker: def __init__(self): self.current_st...
by MrYsLab
Sat Sep 22, 2018 1:16 pm
Forum: Scratch
Topic: Using capacitive sensor MPR121 with Scratch
Replies: 2
Views: 7492

Re: Using capacitive sensor MPR121 with Scratch

The MPR121 is an i2c device and there is no simple way to interface i2c to Scratch. Each i2c has its own command/control protocol. If you feel ambitious and have some Python experience, you can try creating your own Scratch extension using the s2-pi library as a basis: https://mryslab.github.io/s2-p...
by MrYsLab
Tue Sep 11, 2018 6:17 pm
Forum: Python
Topic: Quadrature encoder serial pins question
Replies: 11
Views: 1235

Re: Quadrature encoder serial pins question

@danjperron is correct. Sorry, I have been playing with Arduinos recently and my brain was stuck on 5v GPIO. Here is a link to building a voltage divider: https://elinux.org/RPi_GPIO_Interface_Circuits
by MrYsLab
Tue Sep 11, 2018 5:47 pm
Forum: Python
Topic: Quadrature encoder serial pins question
Replies: 11
Views: 1235

Re: Quadrature encoder serial pins question

Since the output voltage specs show a range of 0.05 to 4.8 volts you can attach it directly to GPIO pins of your choice.

Here is a link to a simple Python program that should get you started:
http://abyz.me.uk/rpi/pigpio/examples.h ... encoder_py
by MrYsLab
Sun Sep 02, 2018 6:55 pm
Forum: Python
Topic: need help with a project flash text on button press
Replies: 1
Views: 165

Re: need help with a project flash text on button press

I set the label text using a StringVar and also use the .after method to reset the label text to "Ready" 200 milliseconds after the label is changed. You can't call sleep since that will block the mainloop. from tkinter import * from tkinter import font as tkFont #import RPi.GPIO as GPIO import time...
by MrYsLab
Sat Aug 25, 2018 9:06 pm
Forum: Python
Topic: building a recognition machine with rpi3
Replies: 60
Views: 8230

Re: building a recognition machine with rpi3

You might want to investigate this site: https://www.pyimagesearch.com/ They offer a free set of lessons https://www.pyimagesearch.com/free-opencv-crash-course/ , one of which is how to build your very own image search engine. I have tried several of the lessons dealing with face recognition on my R...
by MrYsLab
Fri Aug 24, 2018 2:18 pm
Forum: Python
Topic: Code runs, but commands aren't working properly
Replies: 3
Views: 392

Re: Code runs, but commands aren't working properly

This will probably not solve all of your problems but will give you a start. The second element of the list is the direction. You need to test for that direction. I am not sure how you are calculating moving if incrementing or decrementing by 1 since you have four potential directions. You probably ...
by MrYsLab
Fri Aug 24, 2018 1:58 pm
Forum: Python
Topic: Code runs, but commands aren't working properly
Replies: 3
Views: 392

Re: Code runs, but commands aren't working properly

There are 2 issues. First there is a syntax error: def showStatus(): print('--------------------------') print('You are in the ' + currentRoom) print('Inventory : ' + str(inventory)) if "item" in rooms[curremtRoom]: print('you see a ' + rooms[currentRoom]['item']) print("---------------------------"...
by MrYsLab
Wed Aug 22, 2018 10:34 pm
Forum: Python
Topic: Recording while button is pressed.
Replies: 3
Views: 975

Re: Recording while button is pressed.

I am not sure if this answers your question. Below is a snippet of code that will light an LED when a button is pressed and extinguish it when released. I use pigpio since I find it the most reliable and versatile GPIO library for the RPi. To use this code, you will need to start up the pigpio daemo...
by MrYsLab
Tue Aug 14, 2018 7:24 pm
Forum: Python
Topic: How would I create a script to simulate arrow key clicks
Replies: 3
Views: 924

Re: How would I create a script to simulate arrow key clicks

Check out https://github.com/asweigart/pyautogui. This may provide the functionality you are looking for.
by MrYsLab
Sun Aug 05, 2018 5:55 pm
Forum: Python
Topic: how to read 4 sensor with i2c ADS1115
Replies: 1
Views: 7386

Re: how to read 4 sensor with i2c ADS1115

Take a look at this article, it may be of help: https://learn.adafruit.com/raspberry-pi ... sh-ads1115
by MrYsLab
Fri Aug 03, 2018 1:30 am
Forum: Python
Topic: Python interrupts, GPIO and Kivy
Replies: 3
Views: 1182

Re: Python interrupts, GPIO and Kivy

The framework has a rather long history that started with a project called xi https://github.com/MrYsLab/xi , then morphed into xideco https://github.com/MrYsLab/xideco , then xibot https://github.com/MrYsLab/xibot , razmq and finally Python Banyan. Although it may seem somewhat complicated at the o...
by MrYsLab
Thu Aug 02, 2018 10:07 pm
Forum: Python
Topic: Python interrupts, GPIO and Kivy
Replies: 3
Views: 1182

Re: Python interrupts, GPIO and Kivy

I had a similar problem to solve with Kivy when I built a robot using a Raspberry Pi. I am not sure if this is what you are looking for, but you can check out https://github.com/MrYsLab/razmq . The framework used for this project has been updated and is now called Python Banyan https://github.com/Mr...
by MrYsLab
Thu Jul 26, 2018 6:00 pm
Forum: Python
Topic: Creating an alert tone on a python gui on a raspberry-pi explorer
Replies: 1
Views: 301

Re: Creating an alert tone on a python gui on a raspberry-pi explorer

Could you please provide some additional details: 1. Where is the threshold detection being performed - within the GUI or within the client(s)? 2. I don't think the Explorer has a built-in buzzer. What hardware are you using to generate the sound? I have done tone generation for a robot I built usin...
by MrYsLab
Wed Jul 11, 2018 3:32 pm
Forum: Python
Topic: async post call python2.7?
Replies: 3
Views: 1021

Re: async post call python2.7?

Asyncio is not python 2 compatible. The twisted https://twistedmatrix.com/trac/ library may solve your needs. You might also look at tornado http://www.tornadoweb.org/en/stable/.
by MrYsLab
Thu Jun 14, 2018 6:10 pm
Forum: Python
Topic: Tkinter - show images in GUI depending on "robot"-state (in real time)
Replies: 2
Views: 590

Re: Tkinter - show images in GUI depending on "robot"-state (in real time)

Using the after method is good solution. I did just that for the xibot project https://github.com/MrYsLab/xibot . This robot is using an Arduino controller, but I replaced the Arduino with an Rpi 3 in the razmq project https://github.com/MrYsLab/razmq . This project provides for a Kivy and a remi (w...
by MrYsLab
Thu Feb 01, 2018 9:06 pm
Forum: Python
Topic: Speedmeter raspberry "tkinter interface help !"
Replies: 1
Views: 384

Re: Speedmeter raspberry "tkinter interface help !"

Here is a very simple example of updating a label within a tkinter program. This is written for Python3. I am simulating your speed calculator in the tick_up method. Tkinter has its own event loop that essentially owns the system. To break into that loop and run my own code, I use the root.after met...
by MrYsLab
Wed Oct 18, 2017 1:20 pm
Forum: Python
Topic: Sending by mail image files from a folder
Replies: 10
Views: 1422

Re: Sending by mail image files from a folder

I am not sure I totally understand your problem, but perhaps you should call log_txt.close() to flush the file.
by MrYsLab
Tue Oct 17, 2017 2:17 pm
Forum: Python
Topic: Sending by mail image files from a folder
Replies: 10
Views: 1422

Re: Sending by mail image files from a folder

My pleasure.
by MrYsLab
Mon Oct 16, 2017 2:07 pm
Forum: Python
Topic: python3 tkinter make a button look the same
Replies: 13
Views: 3640

Re: python3 tkinter make a button look the same

Try changing

Code: Select all

self.slogan.config(relief=SUNKEN)
to

Code: Select all

self.slogan.config(relief=FLAT)
by MrYsLab
Sun Oct 15, 2017 7:17 pm
Forum: Python
Topic: Sending by mail image files from a folder
Replies: 10
Views: 1422

Re: Sending by mail image files from a folder

Step 1. Sort the files in your directory so that the oldest shows first import os search_dir = "PUT YOUR FULL DIRECTORY PATH HERE" os.chdir(search_dir) files = filter(os.path.isfile, os.listdir(search_dir)) files = [os.path.join(search_dir, f) for f in files] # add path to each file files.sort(key=l...
by MrYsLab
Sun Oct 15, 2017 6:57 pm
Forum: Python
Topic: python3 tkinter make a button look the same
Replies: 13
Views: 3640

Re: python3 tkinter make a button look the same

I am not sure if this is what you want, but the "Hello" button listens to presses, but never changes its look. from tkinter import * class App: def __init__(self, master): frame = Frame(master) frame.pack() self.button = Button(frame, text="QUIT", fg="red", command=quit) self.button.pack(side=LEFT) ...
by MrYsLab
Sat Oct 14, 2017 10:34 pm
Forum: Automation, sensing and robotics
Topic: Adafruit_PWM_Servo_Driver on Raspian Stretch
Replies: 3
Views: 1081

Re: Adafruit_PWM_Servo_Driver on Raspian Stretch

Have you enabled i2c with raspi-config after installing stretch?
by MrYsLab
Sat Oct 14, 2017 12:32 am
Forum: Python
Topic: Tkinter adding an imag
Replies: 4
Views: 3608

Re: Tkinter adding an imag

I think this Python 3 version may help: import tkinter as Tk # image for background was sized 600x400 # image for canvas was sized 100x100 root = Tk.Tk() background_image=Tk.PhotoImage(file="/home/pi/tkstuff/mry.gif") background_label = Tk.Label(root, image=background_image) background_label.place(x...
by MrYsLab
Fri Oct 06, 2017 5:35 pm
Forum: Python
Topic: Integrated Python GUI builder and IDE
Replies: 10
Views: 33686

Re: Integrated Python GUI builder and IDE

I have used remi https://github.com/dddomodossola/remi and its WYSIWYG editor. It generates much of the code (which is very readable and easily modifiable) and support has been great. You can take a look at one of my projects using remi here: https://github.com/MrYsLab/razmq . This project also has ...

Go to advanced search