ElapsedTime - Multiple Movements
Right now our robot should move forward 3 seconds then stop. What if we wanted our robot to do something else after those 3 seconds? How do we request our program to continue?
To start let's duplicate our existing loop. We can right click on a block to duplicate it. In this case, since our block is a loop, it will duplicate everything within the loop.
![](https://docs.revrobotics.com/~gitbook/image?url=https%3A%2F%2F1359443677-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FUOOiQ4S2QcMWmVoSmeQ8%252Fuploads%252FIH580ftCOlCdY2fkqfzV%252Fduplicateblock%2520%281%29.png%3Falt%3Dmedia%26token%3D97cfdacb-2a16-4da3-b5eb-b6615d62c717&width=768&dpr=4&quality=100&sign=28bf49de&sv=1)
We can snap our second loop below the original, however something is still missing. If we want our second loop to start we need our timer to first reset! We can add a block between our two loops.
![](https://docs.revrobotics.com/~gitbook/image?url=https%3A%2F%2F1359443677-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FUOOiQ4S2QcMWmVoSmeQ8%252Fuploads%252Fwqh3zs7BaP3MIsWxTr5f%252Fimage.png%3Falt%3Dmedia%26token%3D9d0ced33-7967-467e-b338-00fe188dbe26&width=768&dpr=4&quality=100&sign=1072decc&sv=1)
Notice our second loop also has a call for telemetry data, however the name is the same! Let's edit it to be "Number of Seconds in Phase 2". Keep the names in mind if you duplicate additional loops.
Quick Check!
Give your program a test to see what happens. Think about the following while testing:
How long does the robot move?
Could you tell when the robot switched between Phase 1 and 2?
What happens if we change the power in the second loop?
Reversing Movement
Having multiple loops with different amounts of time can give us a lot of power to help our robot navigate an area. For now let's have our robot complete it's first movement forward for 3 seconds, then reverse back to the start.
This simply requires changing our power in the second loop to -1 !
![](https://docs.revrobotics.com/~gitbook/image?url=https%3A%2F%2F1359443677-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FUOOiQ4S2QcMWmVoSmeQ8%252Fuploads%252FHj5rKvP5DsvAyuHEzpAV%252Festimatedfull.png%3Falt%3Dmedia%26token%3D6b7f607e-837a-492c-929a-66ff2f2b95d3&width=768&dpr=4&quality=100&sign=5ff0b166&sv=1)
Last updated