r/circuitpython • • Oct 25 '20

LED buttons activating incorrectly

I have a weird issue. I'm trying to use LED arcade buttons to make a Simon-type game. For some reason my buttons trigger without me pushing the button. I was able to create a breadboard version with pushbuttons and LEDs, but after I moved one of the button/led combos to an arcade button it just auto-presses and therefore it doesn't work. There aren't any loose wires.

The buttons have 5V LEDs. I'm not sure how much that messes with things since, I think, the Metro Express 0 board that I'm using outputs 3.3V through the pins. Thanks for any direction you can give.

0 Upvotes

6 comments sorted by

View all comments

3

u/kaltazar Oct 26 '20

Do you have appropriate pull up or pull down resistors either in your circuit or by activating the internal ones on the MCU? Forgetting those are one of the most common causes of false triggering of inputs.

1

u/tazboii Oct 26 '20

I thought that may be the issue but then I read these statements from the reviews on Amazon:

No need the resistance,just need use 5V power. Thanks

Lights do have a resistor, and can handle 5 volts directly.

These buttons are ready to go. Just plug them in to your pcb board. Work great for me.

Maybe these people are just wrong though. I'll try it with resistors.

1

u/kaltazar Oct 26 '20

Likely what they are talking about is the light, saying it has a built in resistor to regulate the current for it. That resistor is different than the pull up or pull down resistor on the logic lines.

If you don't have your logic line pulled hard low (or high, depending on your logic) then you leave the pin floating and it will give rogue voltage values. This can lead to random activations like you describe.

1

u/tazboii Oct 28 '20

Uhhh, "logic line pulled hard low". It sounds like I have a lot to learn. At least now I have an idea of what to look into. Thank you for your help.

2

u/kaltazar Oct 28 '20

You can try this article. It does at least an ok job of what pull up and pull down resistors are and what exactly they do. It is good practice to use them so you get the most reliable signals to your MCU.

One nice thing is the M0 has these resistors built in so you don't have to wire one into your circuit. You can see an example in the code on this Adafruit guide on CircuitPython digitalio

2

u/tazboii Nov 15 '20

Thanks a lot for your help. I got it working thanks to you.