Help understanding ELSE command
Don M
Posts: 1,653
I am monitoring buttons. When I press the button "N" it turns on the output as expected. However when I release the button the output stays on. So I added an ELSE command but it won't compile. Am I using the wrong command?
When I press the "X" button it turns off the output as expected.
When I press the "X" button it turns off the output as expected.
repeat case key_pressed "X" : ' STOP key pressed outa[RLY_UP..RLY_DN] := 0 ' turn off table motor relays "N" : ' MINUS key pressed outa[RLY_UP] := 1 ' turn on table up relay vfd.SetRowCol(2, 0) ' position cursor on VFD to second line vfd.PrintStr(string("Table UP")) ' display message on VFD else outa[RLY_UP] := 0
Comments
You are looking for OTHER.
Tried your idea but it tells me that OTHER has to be at the end of the method. I tried indenting different ways and get other errors where it expects instructions or variables. When I placed it at the end it still didn't turn off after releasing the key.
I'll show more of the CASE loop. Sorry I didn't include it all previously.
Something I am missing here...
And this...
As for "Expected an instruction or variable". When it gives you this error it will highlight something. It is telling you this highlighted thing is not defined. It may be an needed object or variable. Make sure your variables are defined globally in a VAR block or locally after a "|" after your PUB/PRI declaration. Or you may need the "vfd" object declared in a OBJ block.
Here's the code...
I think the problem is with this line: "if Pressed_Key > 0"
Assuming Pressed_Key is set to 0 when nothing is pressed (I'm not sure this is how it works), the cog that controls your IOs never gets the update that nothing is being pressed.
The line of code that makes this now work is: repeat until kp.getrow == 0