Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

Why does the state of a "momentary button" alternate?
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Why does the state of a "momentary button" alternate?

by himoh82538 on Sat May 29, 2021 5:39 am

Basically, I just need a way to tell the microcontroller "to do something" over the Internet. Before that, I was telling it using a physical push button, and I was using digitalRead returned LOW when pressed, and HIGH when released (the example I had followed worked like that, so I copied that. I am not sure if this could be the other way around).

Now, I looked at the list of "Blocks" and the "Momentary Button" seemed to be the closed one for what I want to do. I just need a "clicked" event, but the "Momentary Button" seems to be generating two events, HIGH and LOW, for one mouse click. And by default, pressed was HIGH and released was LOW. That was the opposite of the physical push button, and it was confusing, so in the Block settings, I set the "Press Value" to "0" and the "Release Value" to "1", so that pressed would be LOW(0).

But there it works in a weird way. I had expected that the order would always be LOW(0, clicked) and then HIGH(1, released); that is, always returning to the released state (1). But in reality, the order keeps alternating, so the last value is sometimes 0 and sometimes 1, as you see below in the screen captures. What gives?

damn.PNG
damn.PNG (36.05 KiB) Viewed 195 times
Attachments
damn2.png
damn2.png (27.49 KiB) Viewed 195 times

himoh82538
 
Posts: 3
Joined: Fri May 28, 2021 11:45 pm

Re: Why does the state of a "momentary button" alternate?

by himoh82538 on Sat May 29, 2021 8:47 am

PS: I am not sure, but after some more testing, it seems that it only (or mostly) happens when I tap the button with a finger on an Android phone. If I click the button with a mouse on Windows, it does not seem to happen (I could not test a lot because of the throttling for the free version).

himoh82538
 
Posts: 3
Joined: Fri May 28, 2021 11:45 pm

Re: Why does the state of a "momentary button" alternate?

by brubell on Tue Jun 01, 2021 10:01 am

This might be an issue with the Android browser - could you try adding a switch block instead of a momentary button? It'll should retain state.

brubell
 
Posts: 1381
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.