05-05-2015 09:06 AM
Hi
i am trying to build a project which logs time when a button goes high the first time after a traget time is reach.and in the same way i want to know the last time a button was pressed .
i have made it already , however, i want to reduce the code is there any simple way of doing this.
05-05-2015 10:23 AM
Try using an Event Structure. You can do all of your comparisons in one event case and then use the result to determine which indicator to update.
05-05-2015 10:37 AM
05-05-2015 01:46 PM
You only need one loop and you don't need any local variables.
Place a string array with two elements in a shift register (stor, last press) and replace the approriate one depending on the state.
You could also use a string in a shift regsiter and append a line with a time and description whenever a button is clicked, for example.
You need to be very careful the way you are doing time comparisons, because the numbers are compared alphabetically as strings and the times roll over at midnight. For example if you would start the code right before midnight, the lower loop would stop immediately.
05-05-2015 01:56 PM
@altenbach wrote:
Place a string array with two elements in a shift register (stor, last press) and replace the approriate one depending on the state.
I would actually just keep the timestamp instead of the strings. This would make the calculations a lot simpler. It is easy enough to change differences to strings when you have to report.