Detect Button Presses

Hi. Been awhile since I was here last.

I have an 8 button buttonpad. It works really well for triggering events. However, I'm trying to do something that may or may not be possible.

I would like to make a rule that detects a sequence of button presses and loads them into a variable. So button 1 would add a "1" to the variable, button 3, a 3, and so on. Is this even possible?

Thanks in advance for any advice.

The number of the button pushed is in the string %value%.

So all you have to do is append that to your string variable, like this:

I pushed buttons 1, 4 and 2, and had initialized the variable to :

This is appending each button number to the string variable.

2 Likes

I think Bruce has the best solution, which technically is concatenating characters into a String. But since you didn't explicitly mention your Variable type, and used the verb "add", is there a chance you actually meant arithmetic? As in, "Add 1 to the running sum"?

Looks great! I'm in the middle of installing 2 new Zwave switches so I'll give that a try when I'm done and let you know how it went!

Thanks!

Oh sorry for the confusion. That sounds like an interesting thing too, but in this case I wanted to be able to populate a variable with digits that could be used for a comparison. I'm using the Remotec 8 button pad and was just trying to figure out how to use it to enter a password. Eventually I will probably get a number pad but for now was just wanting to experiment with what I have. I think I read that the Ring button pad is compatible but I guess that's a topic for another day.

Thanks for the reply!

Cool. Just be aware that concatenation may "blow up" your variable by making it longer than you intend, as more buttons get pressed. I don't believe HE offers a method (in RM 5.1 ► Variable Math) for taking the LEFT$() of a string, for instance, so if your password is 4 digits long, there's risk of it matching "1234" but not "12341234".

I would suggest exploring WebCoRE for fancy manipulations, or simply resetting the variable to something predictable (either empty { } and/or an initialization character as Bruce did) between uses.

Ah, thanks for that.

I thought about trying it with Webcore, I have a lot of pistons I've done over the years. I haven't done much with Rule Machine though, and I have a few days off so I thought maybe I'd try it there. But you're right, Webcore can do a whole lot!

I played around doing this. You might need a plan for what to do if you make a mistake and want to erase and start over. I also experimented with it timing out so 30 seconds after starting to enter a passcode, it would automatically reset to null.

Hi Stephen

Good ideas! Finished installing my switches and as soon as I clean up and put tools away I'm going to start playing around with it for a bit.

I'm not quite sure you you entered that last line. I understand the logic, just not sure how to write it.

Which line?

Set Button string to '%button string%%value%(:1422)'

I went to set variable and can't figure out how to enter the rest.

Ah, OK! I haven't played with Rule Machine enough yet I guess, still trying to figure out how to get to the things I want!

Thanks!

Got it working. Thanks a lot for your help, now I need to figure out how I want to use it. I owe you a cup of coffee!

Remind me to show you guys a fun routine I created (using Reactor Multi-Hub) that mimics the game of Lights Out on a 3x3 "grid" comprised of 9 switch-controlled lights. Each button press yields a "move", and you keep making moves until all the lights are off in order to "win".

Would be fairly easy to convert to RM on HE — albeit lacking entirely in Array() functions or bitwise XOR operator AFAIK — and even easier using WebCoRE. Doing all this in the Dashboard UI could be a truly fun exercise, and trivially easy using virtual buttons!!

1 Like

That looks cool! Reminds me of some of the things we did on UNIX with C programming when I was first learning. I don't know anything about the platform you did it in but would be fun to learn when I get some free time!

1 Like