Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //If your DyIO is using a lower voltage power source, you need to disable the brownout detect
- dyio.setServoPowerSafeMode(false);
- ServoChannel srv = new ServoChannel (dyio.getChannel(9));
- //Loop 10 times setting the position of the servo
- //the time the loop waits will be the time it takes for the servo to arrive
- srv.SetPosition(15);
- float time = 5;
- System.out.println("Moving with time");
- for(int i = 0; i < 3&&!Thread.interrupted(); i++) {
- // Set the value high every other time, exit if unsuccessful
- int target;
- int setter;
- System.out.println("SPOT1");
- srv.SetPosition(160, 0);
- System.out.println("SPOT2");
- Thread.sleep((long) (time*120));
- srv.SetPosition(30, 0);
- //This will move the servo from the position it is currentlly in
- // pause between cycles so that the changes are visible
- Thread.sleep((long) (time*120));
- }
- System.out.println("FAIL");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement