Home Applications

Discussion

Left ArrowBack to discussions page
abialevich1abialevich1 Posts: 2 Recruit
How to write a program to turn LED ON when the button is pressed and let it ON when the button is released, and then turn LED OFF when the button is pressed and let it OFF when the button is released?

The code that I have bellow does not  work.

   BeforeStart
     OldButton≔ False 
     State≔ False 
//////////////////////////////////////////////////////

   Thread_2

     Button≔digital_in[2]

     LED≔digital_out[1]

     If (Button≟ True ) and (OldButton≟ False )

       If State≟ False

         Set DO[1]=On

         State≔ True

       Else

         Set DO[1]=Off

         State≔ False

       OldButton≔ True

     ElseIf (Button≟ False ) and (OldButton≟ True )

       OldButton≔ False

     sync()


Comments

Sign In or Register to comment.
Left ArrowBack to discussions page