ok I think I understand what is happening look I think the problem you have is not the script but that you are not connecting your button correctly.
Here I leave you how you should connect it, being the blue cable the pin that you are going to occupy the black GND and the red 5V, you will also need a 10K resistor
Why is resistance needed here? How to make a way to go without resistance?
On raspberry pi zero no resistor is required, I connect GND to Pin37 it was change from 1 to 0.
no friend, in fact the RX and TX pins are fine I have been testing them and I have not had problems with them, and the truth is that I do not remember the pull-down pins very well but I think that 15 and 16 are in pull-down and for the pin command is without parentheses.
or another way to change the state of the pins is with a python script,
also if you want to check if the pin is pull-down you can use the following command to declare the pin as pull-down or pull-up, just one thing the pull-up is almost only for output
Error Code:
RuntimeError: Failed to add edge detection
No use Resistor:
To avoid using resistance I have
tried to set pull down on pin 31 but GPIO.input still reads random values, if I put 10k resistor it works instead.
Hello, in fact something like this I already imagined could happen but it is the fault of the RPi.GPIO library since as far as the problem goes is the identification of the board I tried to try it in many ways and the only solution I saw in one was With resistors, I’m still going to tell you that the solutions I tried and that worked for me was to take the original ROi.GPIO apo and make changes to it with respect to the sinovic version to go to version 0.6.4 where event detection already worked for me,
Another solution that I could use is to modify my own library that is based on Adafruit Blick, where it only performs copulation on /dev directories, even though I think that any of them can work for you. Also, I will tell you that this problem does not only happen on this board, but I also had it on the raspberry pi Zero w with gpiozero but I solved it by changing gpiozero to RPi.GPIO in addition to changing the gpio bms register of the raspberry pi Zero w the 3b+ although at the time of loading the library I had to make modifications when doing the installation
if I do a clean reinstall via script.sh the Rpio.GPIO library update to make callback event calls work correctly?
No Resistor 10k:
To avoid the use of the 10k resistor it is possible to do something, I forced with calls python set pulldown on the pin but no solution: GPIO.setup (31, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) without resistor but GPIO.input on the pin returns to reading 0-1 random values
The truth is that I had tried it but the use of gpio was broken worse I did it with old images I never tried it with my images so it could work or I could send you the error that it is only for RPi
and it still returns you like this because it detects the pin in false as if it had nothing connected, that’s why the value is random
hey look I took a moment to check if you really couldn’t put the pins in pull-down and it turns out that if it’s okay what happened when I gave you the gpio command -g write 7 1
estaba mal era gpio -1 write 7 1 hay fue mi error pero en efecto funciona muy bien igual si quieres le di una actualizacion rapida a mi repo para que tengas mas detalles
I write type down on physical pin board = 7, but button_state_m2z.py always reads only low state in input, no change of state detected when the wires are joined : pin7 + pin39 (gnd).
look right now I can’t post a drawing but it’s the same as before just connect one pin of your button to GND and the other to pin 7 and that’s it
also in the capture that the post does not use any 10k resistor I find it strange that it does not work for you, could you check if your wiring is properly connected first or maybe your button was damaged
Well, as I mentioned before, remember that what I basically did was about writing the library, obviously it is not going to be perfect and it has its ups and downs, and about your other question about whether the pins can be established without forcing the start, the answer is yes, but why At the moment I don’t have the time to make modifications to the current library, I have my own as I mentioned, but I don’t release it because it still has many bugs. In fact, mine does have edge detection on the board, but I haven’t corrected the value either. of the pins that’s the reason I haven’t released it yet
to get the first version out maybe in a few months and about other libraries I couldn’t tell you what I can tell you is that if you know the c++ language you can create a program that reads the input of the buttons with wiringpi