Hot answers tagged

4

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.


4

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


3

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.


3

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. https://www.amazon.in/Solnoi-Electronics-PAM8406-Amplifier-Potentiometer/dp/B07HDP7222/ref=mp_s_a_1_10?keywords=stereo+amplifier+3w&qid=1584776772&sr=8-10


2

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.


2

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 ...


2

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 ...


2

You can create a function that takes no parameters: def begin_time_5(): begin_time(5) begin.when_pressed = begin_time_5 This is called "currying". Alternatively, use a lambda: begin.when_pressed = lambda: begin_time(5)


1

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 ...


1

Well if it’s tight you want: def begin_time(time = 5): print(time) 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.


1

I realize I'm answering a question that is years old, but there is one that hasn't been mentioned yet: gpiozero. https://gpiozero.readthedocs.io/en/stable/ It should already be installed on new versions of Raspbian. https://gpiozero.readthedocs.io/en/stable/installing.html


1

Don't continually call the dutycycle function. You are probably resetting its function many times per second. Try something like ... import time ... if len(sys.argv) > 3: # converteer de waarde 255 tot max 100 voor PWM. roodwaarde = (int(sys.argv[1]) * 100) / 255 groenwaarde = (int(sys.argv[2]) * 100) / 255 blauwwaarde = (int(sys.argv[3]) * ...


1

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 ...


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible