|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Counting up and down with a switch
Quote:
I am attaching a snippet that would count up and down as described, - note that it will go 1 or 0 always. I am also attaching a snippet of what it could look like with the second switch. I don't have access to LabVIEW for FRC right now, so I am posting a vi that could have the switch read wired into it. I have made it in the form of an FGV, but the point is just the memory of the last value should be used (through either shift register or feedback node) |
|
#2
|
|||
|
|||
|
Re: Counting up and down with a switch
Quote:
. |
|
#3
|
|||
|
|||
|
Re: Counting up and down with a switch
Quote:
To accomplish an equivalent of what I posted in Java, it would require static variables. i.e. class Counter { private static boolean LastUpCount; private static boolean LastDownCount; private static int count; public static int counter(boolean upCounter, boolean downCounter) { if(upCounter && !LastUpCount) { count++; } if(downCounter && !LastDownCount) { count--; } LastDownCount = downCounter; LastUpCount = upCounter; return count; } }; Last edited by mshafer1 : 15-02-2015 at 14:37. Reason: clarify |
|
#4
|
|||
|
|||
|
Re: Counting up and down with a switch
Thanks everyone for all the replies. The Java code that sets the up and down source makes the most sense to me so will try that first. I'll report back my findings.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|