Announcement

Collapse
No announcement yet.

using momentary button to set an output.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • using momentary button to set an output.

    I want a momentary button to set an output pin when it is pressed. The tricky part is to reset the output when the button is released! I suspect it is achievable using the variable 'newval' associated with a magic event.I cannot find an explanation of how this variable is handled. If it goes hi when the button is pressed then lo when it is released then my troubles are over. Anyone help please.

  • #2
    Good day,

    The value that will be passed by the button to 'newval' will be 0 when the button is set as a momentary switch. You might want to use "Both" on the momentary field of the button's object inspector where it should return 1 or 0 depending on the button state, from there you can check if you need to pull the pin high or low.

    Best Regards,

    Comment


    • #3
      Many thanks for your prompt answer. I will try using 'both'. Is there a code sample or project that uses a similar button?
      regards
      Peter

      Comment


      • #4
        Hi,

        I've attached a simple project that has a button linked to a Magic Event. Inside, the 'newval' value is checked through a conditional statement for pressed and released actions, you can insert your code for changing the pin output there.

        Best Regards,
        Attached Files

        Comment


        • #5
          Many thanks
          I will look at this closely.
          best regards
          Stay safe
          Peter

          Comment

          Working...
          X