There are numerous errors in the script.
time module is not imported
PIRinPin is not defined.
AmountMotionsDetected is not defined, set as a global, or incremented.
Once those errors are corrected the script works properly.
Therefore you have connected to the wrong GPIO or you are using very long wires.
Only reasons I would NOT use them are:
You end up with a connector not connected to anything and this can be misleading long term as you may wonder why
Some can be physically larger
Some can cost more though not normally an issue for the hobby
Labels on the switch can have both positions marked
I would start by debugging this on the command line using gpio. gpio readall can tell you if the pin gets configured correctly, and whether it changes the state. See if the pin changes state when you pull it to 3.3V / GND via a resistor. When that works, get back to your code and see how it behaves. Once it works, switch to an internal pulldown.
You need a stereo audio amplifier between the Pi’s analogue audio out and your speakers.
If you’re ok soldering something like the following should work and could be powered from the Pi’s 5V.
I can confirm that I also haven't had any problem powering a low profile 5V Noctua 40mm x 10mm fan from the 5V and GND pins. These pins are always on. This is on a Raspberry Pi 3B+ used as an Octoprint server.
The power drain is minimal.
Hardware does what you tell it to do just as the software does, unless you rely on undefined behavior. The difference is that software projects use decent compilers even for hobby grade stuff, so everyone gets a warning when reading a variable they didn't initialize. Leaving an input pin unconnected (the hardware equivalent) will also produce a warning in ...
To answer your question, yes it is probably perfectly fine to use an SPDT in place of a SPST. Depending on the design, if it is soldered in place it may even add some additional mechanical stability to the switch.
But to also clarify it is NOT like 2 separate SPST switches. It just allows for making a connection in the normal (unpressed) state, in ...
You can create a function that takes no parameters:
begin.when_pressed = begin_time_5
This is called "currying".
Alternatively, use a lambda:
begin.when_pressed = lambda: begin_time(5)
Your problem seems to be related to "electrical bounce" which is caused by electrons arching from one wire to another as your contact wires (or switch contacts) come close together. Basically, your computer reads multiple "contacts" before your subroutine has a chance to finish executing.
The way to get around this is by stopping the loop that waits for a ...
Well if it’s tight you want:
def begin_time(time = 5):
begin.when_pressed = begin_time
Personally, I find this easier to understand than the more pythonic lambda :-) but have to say the lambda version has more flexibility for changing the value.
I realize I'm answering a question that is years old, but there is one that hasn't been mentioned yet: gpiozero.
It should already be installed on new versions of Raspbian.
Don't continually call the dutycycle function. You are probably resetting its function many times per second.
Try something like
if len(sys.argv) > 3:
# converteer de waarde 255 tot max 100 voor PWM.
roodwaarde = (int(sys.argv) * 100) / 255
groenwaarde = (int(sys.argv) * 100) / 255
blauwwaarde = (int(sys.argv) * ...
The post you link explains pretty well, but it does not explain how they selected the 2K resistor.
They do explain why, though. At the end of the question:
Since the Raspberry Pi GPIO PINs work with 3.3V, I had to build a voltage divider to convert the 5V output of the sensor to 3.3V. Assuming the left-most resistor on the breadboard is 2K ohm and the ...
If you want a really silent fan, I suggest powering a regular fan with a lower voltage. The safest bet is to get a 5V fan and try it with 3.3V: it will almost certainly rotate at roughly half the RPM, which reduces the noise a lot. If it doesn't work, or the airflow is not sufficient, you can still power it with 5V.
Another option (that I personally use) is ...