(04-13-2020, 05:11 PM)sisim Wrote: I used another script, showing 0 or 1 every 0.1 second and I tested it with several GPIO, this is what I get:
Code:1
1
0
1
0
1
1
0
1
0
1
1
0
1
0
1
0
0
1
0
1
0
1
1
0
1
0
1
1
0
0
1
1
I'm not sure if I can help here but I believe that you had the same problem I did when I moved from Volumio. I had gpio pins 5 and 6 (default high )connected via buttons to ground as the documentation suggested configuring for the opposite voltage as described here
The other gpio pin (13)(default low) I had conected to 3.3V.
however when I came to moode it didnt work properly .
as kent said
Quote:OK, so now I've actually read Tim's earlier reply:
Code:
Code:GPIO.setup(sw_1_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
I haven't played with the GPIO package but I interpret this line to mean the pin is enabled as an input pin with its internal pull-up resistor (within the RPi) enabled, which means the pin is already tied to +3.3v through ca 50Kohm. If this is so, then a push button which momentarily connects the pin to +3.3v won't cause a transition.
I expect you have either to change the code to enable the pull-down resistor or to change the switch to connect to ground instead of +3.3v.
Or I could be off in left field again
Regards,
Kent
the code for every pin is set to pull up or (high ) when no button is pressed this stops it foating as explained in this excellent site I discovered here
This might be why you see the numbers fluctuating between 1 and 0
I would suggest that either you wire all pins you use to ground and keep using Tims script or keep your wiring that you have and change the
Code:
pull_up_down=GPIO.PUD_UP
Code:
pull_up_down=GPIO.PUD_DOWN
for each Gpio you have conected to 3.3V in Tims script .
although I'm not sure if Tim's script would be overwritten each time you updated Moode and you would have to chnage the value again .
I hope this helps as its something I've learned today based on reading that site regarding pins floating unless they are pulled (in software) using the internal resistors on the PI or an external pull up/down resitors is used.
Unfortunately (like many) I didnt read the first post in this thread properly and it says
Quote:On the hardware side, you set your hardware button to connect the ground pin of your RPi with a GPIO pin of your choice
regards
Tim ( another one )