Pibrella & push buttons


We are using python to program the pibrella and have been using the push button to make one of the LEDs come on.
Does anyone know the code to make a different LED come on when the button is pressed twice or held down?
This is a function commonly used in electronics to make a push button have more than one function but I’m not sure how to code it.


For a double press I would use a variable to iterate (reset after a set lapse of time, or once the trigger has occurred).

For holding down, I guess you could check the input value a couple of times say a second apart but I think that is a bit simplistic and you could run into corner cases where the if statement resolves to true when the operator was in fact taking a couple of separate shots.

… hopefully someone can give you a less tentative answer, I’m definitely interested myself in the second part of your question.


Thanks for your reply. How would I go about setting a variable (sorry I am new to python). It might be ok for the level we are at the moment.



I’m not familiar enough with the Pibrella to give you an example code, assuming I’m even ballpark correct about the approach.

Still, I’ll try to mess about with my Explorer later and see if I can come up with some general format for you to inspire yourself from.

… that said I would greatly recommend you check out even a basic Python reference book as I think your requirements have gone a bit past what you can do, you no doubt are using variables already and I think it’s important to know what’s what in your code ;-)

But bear with me, I’ll be back, but I’m concerned that what you are looking for is a cut and paste snippet and I think I’m the wrong man for that (although I could probably dig into the Pibrella lib and assemble something close to usable).


Many thanks for any help