Please use Autoformat, or Ctrl T, in the IDE before copying. That makes the code a lot easier to read.
Writing comments telling the intention of the lines is good practise. Now it looks like a djungle of positions.
Thanks. I wonder if it compiles. The two last rigjt curly brackets on the same column is a suspect.
For time measuring use the same technic as for positions. When You make a reading of the encoder note the time like this:
Railroader:
Thanks. I wonder if it compiles. The two last rigjt curly brackets on the same column is a suspect.
For time measuring use the same technic as for positions. When You make a reading of the encoder note the time like this:
thanks for your answer I know how to write the formula to calculate the speed as you mentioned it is distance / delta time but for distance I need delta position / delta time and in my code the delta position is :
(newPosition1-oldPosition1)
and in my code I set oldPosition to newPosition so distance equals to ZERO and the speed equals to ZERO too!