Home› Applications
Discussion
Back to discussions page
abialevich1
Posts: 2 Recruit
Turn ON LED when button is pressed and then released |
75 views
|
Answered | |
/ Most recent by matthewd92
in Applications
|
2 comments |

in Applications
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.
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
-
abialevich1 Posts: 2 Recruit
I solved it. It is working now.1 · FacebookTwitter -
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
Can you post up what you changed to solve the issue so others can see as well please.0 · FacebookTwitter