Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. //If your DyIO is using a lower voltage power source, you need to disable the brownout detect
  2. dyio.setServoPowerSafeMode(false);
  3. ServoChannel srv = new ServoChannel (dyio.getChannel(9));
  4. //Loop 10 times setting the position of the servo
  5. //the time the loop waits will be the time it takes for the servo to arrive
  6. srv.SetPosition(15);
  7. float time = 5;
  8.  
  9. System.out.println("Moving with time");
  10. for(int i = 0; i < 3&&!Thread.interrupted(); i++) {
  11. // Set the value high every other time, exit if unsuccessful
  12.  
  13. int target;
  14. int setter;
  15.  
  16. System.out.println("SPOT1");
  17.  
  18. srv.SetPosition(160, 0);
  19.  
  20. System.out.println("SPOT2");
  21.  
  22. Thread.sleep((long) (time*120));
  23.  
  24. srv.SetPosition(30, 0);
  25. //This will move the servo from the position it is currentlly in
  26.  
  27. // pause between cycles so that the changes are visible
  28. Thread.sleep((long) (time*120));
  29.  
  30. }
  31.  
  32. System.out.println("FAIL");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement