As joan's answer has already pointed out the misunderstanding here is likely how to define and use a function in Python. Joan's approach will sure solve the immediate problem and make the program work. I will however address the underlying issue that is not so much related to the Pi but general Python programming.
So how to go about defining and using a ...
This device is and open collector sinking (see the datasheet).
That mean that you need to connect a pull-up resistor on the output.
So if you connect the output pull-up resistor to the Pi 3.3V and the output to the Pi GPIO it will work.
If the device outputs a square wave (i.e. a digital signal) you should use a level converter. These are quite inexpensive and guaranteed safe. They are readily available on-line and from most retailers who sell Pi products.
https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide shows one common option.
See also https://...
Note that I am the author of pigpio so will be biased in my assessment of the different types of PWM.
Actually there are three different types of PWM supported on the Pi.
Fully hardware PWM
This type of PWM is generated by the Pi's PWM peripheral.
The timing of the pulses is controlled by the PWM peripheral.
It is the most accurate and arguably the most ...
When you have a recursive function like this (one with too much depth potential), you need to convert it into a loop. In this case you have two functions alternating calling each other:
This will loop forever (as does the original version, you are exiting on a signal), but you can also use some kind of state as a ...
That's one way of doing it - it will work. The better way is to use GPIO.wait_for_edge(17, GPIO.RISING) which will pause at that line until the button is pressed (on a RISING or FALLING edge).
However, BOARD numbering pin 17 is not a GPIO, it's 3V3.
You could also use GPIO Zero which is more intuitive (and uses BCM numbering):
from gpiozero import Button
I guess the reason why you observe this behaviour in the first seconds is that you don't initialize the output state of the led pins. So, those gpios are in a default state (usually it's LOW, but it might be different for specific pins and depend on other configurations).
It will take a while until cap is initialized and that's the delay you see at the ...
Lucky to see this question, I just spent weeks on controlling two servo (SG90) using WiringPi and programming in C, there're three things that I recommend.
1.Using BCM GPIO instead of WiringPi Pin because controlling more than one servo, you might need more than one pin such like 1(WiringPi Pin)/18(BCM GPIO) for another servo, For RPi3 B+ version, it give ...
The crystal oscillator is 19.2 MHz on all Pi models earlier than the Pi4B. The Pi4B is based on the new BCM2711 which has a 54 MHz oscillator. It is likely that all future BCM2711 based Pis will also be 54 MHz.
Don't use balanced PWM if you want a particular frequency, use mark space.
Balanced will try to achieve the desired duty cycle as "smoothly" as ...
You need to connect the ground of the two Pis together as well as any GPIO you want to use for data transfer.
If the grounds are not connected the Pis can not tell if a GPIO is set high or low by the other Pi.
As @Arnaud suggests it would be sensible to add a resistor somewhere in-line between each Pi GPIO to other Pi GPIO connection. Something of the ...
I don't know what a CrowPi is or what version of Raspbian it is based on.
The config.txt file explains WHY the pins are outputs.
# SPi Related configuration
This sets GPIO 16, 17, 18 as outputs
Info: Enables spi1 with three chip select (CS) lines and associated spidev
dev nodes. The gpio pin ...
Unfortunately I was not able to put it to work using the rpio.poll function
However, I managed to listen to the input pin by using a setInterval() method:
rpio.open(15, rpio.INPUT, rpio.PULL_UP);
var status = rpio.read(15)
I did try to listen every second, ...
Indeed you can, if you want something easy to play with the GPIO I suggest you WiringPi, if you already worked on Arduino it's the same thing but on raspberry.
If i have well understood you you want to make the raspberry play for you ? Some sort of Rogue player?
For doing so you will have to understand the schematic of the button, is it a pull-up or pull-...
A 38 KHz PWM carrier has 38000 cycles per second. Each cycle takes 1 million / 38 thousand microseconds, so approximately 26 microseconds per cycle.
The dutycycle is the percentage time the PWM signal is high per cycle.
Infrared devices use mark space PWM rather than balanced PWM. All you need to know is that mark space means the signal goes from high to ...
That sensor looks like it has an analogue output ! You would need an ADC (analogue to digital converter) to connect that correctly to a Pi.
In this example, we will explain how to use a water sensor to detect the amount of water we have in a tank. We will use the S pin as analog input connecting Arduino, the value read will be higher depending on the ...
The Pi has 3 "components" the CPU, GPIO and Video Core which are relatively independent.
Even when the Pi is shutdown the Video Core continues to run, and the GPIO pins retail their state; only the CPU is not running.
The 3.3V is supplied by separate circuitry and will be present while ever the Pi is connected to a 5V supply.
The best way to reliably ...
This howchoo post shows how to connect an LED to show the status of the Pi. The LED is steady on when the Pi is running, and off after shutdown.
Add this line to /boot/config.txt, and reboot
Connect the TxD pin (GPIO pin 8) to the positive lead of a 2 or 3 volt LED.
Connect a ground pin (e.g. GPIO pin 6) to a 330 ohm resistor, ...
1) substitute a relay for the button press - that way you don't need to worry about voltages, common grounds, pull ups, or pull downs. Eg https://www.instructables.com/id/Control-Any-Remote-From-a-Raspberry-Pi-and-Amazon-/
2) Or find an HDMI switcher with a computer input, for example the ATEN HDMI switcher has an RS232 input.
The button on the HDMI ...
Attach level shifters with different thresholds on two GPIO pins to distinguish more than two states:
simulate this circuit – Schematic created using CircuitLab
Q1 will output 3.3V only when the input is below 0.6..0.8V, otherwise it will output 0.3V or less
Q2 will output output 0V only when the input is above 2.5..2.7V, otherwise it will output 3....
You MAY be able to use the Pi logic levels to detect this, but it would be unreliable. (The trigger point is ~1.3V, but varies from Pi to Pi.)
The only thing you can rely on in <0.8V => LOW; >2.0V => HIGH.
See Electrical Specifications of GPIO and https://www.raspberrypi.org/documentation/hardware/raspberrypi/gpio/README.md
An ADC would be overkill, ...