04-28-2014 07:24 PM
Essentially, when a boolean is pressed a corresponding number should be generated, this buttons are set to switch until released, and the event structure reads the boolean state on mouse up, at this point a value should be generated from 0-9 depending on which boolean is pressed. However on some presses of the booleans the value produced is 0, this is fine for the button corresponding to 0, however for the values 1-9 this is wrong. Any ideas on why this is and how I could fix it would be great?
04-28-2014 07:43 PM
@Alxs93 wrote:
however for the values 1-9 this is wrong.
How is it wrong? What are you getting? Without a description of how something is behaving wrong, it is impossible to tell you how to fix it so it works right.
It is generally better to use the Value change event rather than the mouse up event.
04-28-2014 07:49 PM
If I press the button to produce 1, it will not always produce a 1, sometimes it will produce a 0, the other buttons have the same behaviour in that they will produce the value they are meant to but not every time, they will sometimes also produce a 0. How can I stop random 0's being produced?
04-28-2014 07:52 PM - edited 04-28-2014 07:56 PM
Change the events to Value Change events first. Not sure that is your problem. But if you don't hit the buttons quite right, it's possible you are getting a mouse up event without actually clicking the button correctly.
Put an indicator on your wire going to the Index Array function. It's possible you are sending a a -1 which would happen if the mouse up event fires, but none of your booleans are actually true.
You can eliminate the upper output of the Index array function. You aren't using it.
Try attaching your VI so we can play with it and see what it might be doing.
04-28-2014 08:05 PM
I tried changing the event to value change but that just produces an output for the correct number until the button is released. The desired output would allow the correct number to be produced and stored for use in a calculator style programme. I've attached the VI.
04-28-2014 08:25 PM - edited 04-28-2014 08:47 PM
That's why having an actual VI helps.
First, you are missing an event for number 4.
Second, the appropriate mechanical action for those buttons is Latch When Released. Not Switch Until Released. With Latch When Release, the value change event will work just fine.
Here is the VI cleaned up. Also I put in an alternate method of determining which button was pressed.