How to distinguish multiple GPIO Buttons?
Well, for a small number of buttons, say 8, you can use 8 GPIO pins, each of which entertains one button. But that is a big waste of GPIO pins. For more than 8 buttons, you can use GPIO extenders such as MCP23017, each of which adds 16 more GPIO pins, and greedy you can "easily" (see warning ...
try using systemd, the following is a simple service config, runs as user pi, will restart on failure (to a point, if it always fails immediately, systemd will not try to restart the process continually)
You'd create a file in /etc/systemd/system - perhaps call it something like myservice.service ... the .service is important
While it is possible to connect multiple buttons to the Pi's GPIO and read them in a python loop the second that second "schematic" will not work. Note that ABCDE and FGHIJ columns are connected for each numbered row. Placing the buttons as shown will make it impossible to distinguish between the two buttons on each line. In this particular case one would ...
It is inadvisable, and violates the recommendation in PEP 394 to make python refer to python3.
Doing so (by ANY means) risks breaking your system and any tools which use python2 are likely to fail.
If you want to use python3 invoke it with python3.
If you want to install Python 3.7.2 in addition to the default Python 3.5.3, by all means use update-...
To determine what your program is doing, you need to save the output of the program to a file. Use this type of call to start the program
/path/to/script >> /path/to/log/file 2>&1 &
This will start the program in the background, and send all output (both stdout and stderr) to a file of your choice.
Keep in mind that if the script is long ...
What you need is a button array.
Example you have two rows of buttons
a and A are connected to the same input GPOP
b and B are connected to the same input GPIO
and so on
But they way you tell which button is being pressed is to Power all the capital buttons, check the inputs. Remove power from Capital buttons, power the lower case row, ...
You didn't tell us if you'd tried anything, and so I'll assume that you haven't. If that's the case, I'd suggest you take a look at this answer from Stack Overflow SE. In a nutshell, it suggests that you use David Beazley's Generator Tricks for Python, but the code is actually on Beazley's GitHub page. I think the specific code you'll need is this one
Why are you calling
os.system("sudo systemctl stop serial-getty@ttyS0.service")
os.system("sudo systemctl stop firstname.lastname@example.org")
These are the same interface, and if you aren't using serial console it is better to disable (using raspi-config) then there is no need for sudo.
There is no need to use sudo with /dev/serial0 provided the user is a ...
How can Rpi send text strings to HC05?
I once wrote a couple of python functions to do the following:
Reset HC05 to AT command mode,
Reset HC05 to connection mode,
Write AT command to HC05,
Read reply from HC05.
With these set of basic functions, I can then do the following.
Set HC05 to AT command mode
Usage of that python class will not work with my setup of one motor. I
agree and I want to instead use the GPIO library to control the board
controlling the motor.
Example code I found: import RPi.GPIO as GPIO
I do not know how to edit the code to work with my project.] but I am
using IN1 on the controller board and GPIO2 from ...
I suggest you return to using gpiozero, but select a suitable class.
We don't know anything about your robot (include detail in your question).
I guess it has a single motor with forward/reverse so the following would be appropriate:-
After more testing I found out that there was still active code trying to access GPIO23. As GPIO23 is in use by the kernel, the declaration btn23 = Button(pin=23, pull_up=True) fails with RuntimeError: Failed to add edge detection, which apparently was silently caught in a try/except block.
When an exception is thrown while declaring a Button, the cleanup ...
To answer my own Question at least to a small extend:
VLC seems to offer a something similar to pygame but with the advantage that (to my knowledge) no screen is needed and it plays pretty much every data Format.
Here a quick link: https://linuxconfig.org/how-to-play-audio-with-vlc-in-python
As for the code, Iam still greatful for every advice, especially ...
When you executed this line in step 3:
echo "alias workoncv-$cvVersion=\"source $cwd/OpenCV-$cvVersion-py3/bin/activate\"" >> ~/.bashrc
It should have added a line to the end of your ~/.bashrc file. The line should look something like:
alias workoncv-3.4.4="source /your/working/path/OpenCV-3.4.4-py3/bin/activate"
First make sure that line exists by ...
relevant sections from that post go like so:
step 0: defines the opencv version
echo "OpenCV installation by learnOpenCV.com"
step 3: sets up an alias
# Install virtual environment
python3 -m venv OpenCV-"$cvVersion"-py3
echo "# Virtual Environment Wrapper" >> ~/.bashrc
echo "alias workoncv-$cvVersion=\"source $cwd/OpenCV-$...
I personally would change your functions to be pir.isThereMotion() that returns true/false then you could do
filename = "pircam-" + datetime.now().strftime("%Y-%m-%d_%H.%M.%S.jpg")
This way it will just take a picture ever second while ...
You should move the camera initialisation stuff outside the while loop.
from gpiozero import MotionSensor
from picamera import PiCamera
pir = MotionSensor(4)
camera = PiCamera()
camera.rotation = 180
camera.start_preview(fullscreen=False, window = (50, 25, 640, 480))
You can't use 5 V relay with signal from Raspberry Pi while Raspberry Pi signal is 3.3 V.
So if you used Logic level converter to convert 3.3 V from Raspberry to 5 V then to relay in I think it may solve this issue.
I don't know why most distributors say it should work with raspberry pi while the ideal one for Raspberry Pi is 3.3 ...