Hey
I want to save information when a condition is checked and found to be true but I only want to save the information the first time the condition happened.
In my case, I want to store the time when a motor (with encoder) reaches the target position for the first time. If it reaches, then I want to save the reaching time, and if it reaches again I want my saved time to remain the same as the first time the motor reaches the target position.
I tried this code:
Your code has a bug, there should be no semicolon after the if statement, just a brace {.
Also you have contradictory code, targetAchive always gets set to 0 after it is set to 1. So the first line does nothing. Not sure what you are trying to do.