Creating a Pause Method in Java
I use this often in my robotics code. The reason is simple, it takes the robots time to do things and I need to wait for a microcontroller to perform some action, like get a sensor reading, or move a certain distance, or change heading. It’s very simple, but I will add more robotics code later this week-end, this is just the start.
public static void pause(long ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.
Comments
No comments yet.
Leave a comment