New answers tagged

0

As @joan said in the comments without knowing which specific library you are using it's difficult to be certain. The snippet below uses smbus2 which is supposed to be a drop in/side-by-side replacement for smbus so solutions for either library should be similar, if not the same. It should be as simple as instantiating the bus instance with the required bus ...


0

Have you managed to program these buttons to do anything? Set up my display today using kali Linux and wanted to program them to switch between the LCD display and HDMI.


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


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


0

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.


0

Been in the electronics 30 years, never saw a so poorly designed input circuit. First thing first, never bring vcc (regardless it is 3.3 or 5v) to a input jumper ! Your jumper should be between ground and input. With a pullup, and use a 10khoms pullup not 220R ! Also debounce input reading algorithm goes like this (low level) 1. Read state 2. Compare ...


0

@Marko was pointing me in the right direction. I updated my question and added some links to my research about this issue and came up with the following workaround: if not GPIO.input(PIRinPin) == GPIO.HIGH: return The complete code looks as follows: import RPi.GPIO as GPIO import time AmountMotionsDetected = 0 PIRinPin = 17 def setup_gpio(): GPIO....


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

Your pull up connection is wrong in the image you can see the correct connection


1

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)


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.


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.


-1

A lot depends on what you want the program to do while waiting for the button to be pressed. Button abilities here You could try (untested code though): from gpiozero import Button import time def begin_time(time): print(time) begin = Button(27) # Loop doing nothing till the button is pressed while being.is_held == False: time.sleep(0.01)...


0

Some LCD displays come with SD Cards and have the ability to play from them. A YouTube example for the Arduino is here using the ILI9341 from Adafruit.


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


0

Without connection details this is unanswerable. If you are trying to use a single resistor in the common leg it is no wonder it is unreliable as each LED has a different voltage and only the lowest (usually Red) will work. NOTE coloured LEDs often need >3V so won't work reliably on the Pi - you may need transistors. PS running without a current limiting ...


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


0

set the pullups in config.txt or use raspi-gpio command.


2

You can monitor the Pi GPIO from an Arduino. Note that all the Pi GPIO are 3V3 and there are 28 of them on the 40-pin expansion header. You will need an Arduino with at least 28 GPIO if you want to monitor all the Pi GPIO simultaneously. Although a 5V Arduino will probably see a Pi logic high 3V3 as high it might be safest to use a 3V3 Arduino. Remember ...


2

Servos require a constant input to retain their position. (You can of course remove power to the servo thus preventing it from moving with no input but this is a kludge.) The servo input does not need to come from an active foreground process. You can spawn a background process to supply the requisite input and launch processes to modify the background ...


4

Unfortunately the CPUTemperature class does not support reading from a remote Pi, even if you provide a remote pin factory. There's an issue to add it but it's probably not a priority: https://github.com/gpiozero/gpiozero/issues/581 For now you can try doing it with pigpio itself: http://abyz.me.uk/rpi/pigpio/python.html#file_open


3

You can connect as many wires as you want to a 3V3 pin (pins 1 and 17). Similarly you can connect as many wires as you want to a 5V pin (pins 2 and 4). Similarly you can connect as many wires as you want to a ground pin.


1

From memory. H-Bridge l298n 4 x GPIO 8 Ultrasonic HC-SR04 16 x GPIO IMU-MPU6050 2 x GPIO (I2C GPIO#2 and GPIO#3) 2 Speed Sensors(H206) 2 x GPIO (not sure probably) Servo Motor 1 x GPIO So a total of 25 GPIO. There are 26 GPIO available on the Pis with the 40-pin expansion header. Depending on how the sonar rangers are ...


Top 50 recent answers are included