Jopyth / MMM-Buttons

This module can be used to to connect buttons to your Magic Mirror²
41 stars 10 forks source link

press button twice to trigger #5

Open robinxyz1 opened 6 years ago

robinxyz1 commented 6 years ago

I have a strange issue with button press. I have to press it twice quickly to trigger action. Pressing it just once or holding it down does not work.

Anyone have the same strange issue I have?

bolish commented 5 years ago

Hi @robinxyz1 ,

I'm experiencing same issue on my side. But it's not really consistent ... Sometime 1 press is OK, sometimes, I need 2 press.

I'm even not sure if it's coming from the module or th buttons...

Did you managed to improve the situation on your side?

Note : buttons I'm using : Buttons

Regards

robinxyz1 commented 5 years ago

@bolish Yeah, my problem was because I did not initialize the GPIO pins. I added a startup script to set the pin state and mode for the pins used, that took care of it.

bolish commented 5 years ago

hi @robinxyz1 ,

Thanks for feedback. Is it something different than setting the Pull Up thing? I've already added the following into my config.txt ':

# Change the pull on (input) pins 18 and 20 gpio=18,20=pu

But this doesn't seems to be enough.

Could you please let me know how to do your trick "initialize GPIO pins with startup script?

Regards

robinxyz1 commented 5 years ago

Hi @bolish

MM was my first Pi project, I am not sure if initialization is the right word. My understanding is it sets the pin state (up/down) and mode (input/output).

In /etc/rc.local, I have a line to run a python script.

/usr/bin/python /home/pi/Initialize-GPIO/initialize-buttons.py

this is the content of initialize-buttons.py, I am using 3 pins, two buttons and an IR sensor.

import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

HTH

yhax commented 5 years ago

@bolish make sure you have the button wired correctly i.e. on the pin, and on power (use a resistor) not ground.